diff options
author | Lorenz Diener <[email protected]> | 2017-11-30 16:02:52 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2017-11-30 16:02:52 +0100 |
commit | 7e3a4a17a28f52b186e6453a0d1f43614f110b4b (patch) | |
tree | 48aafcc35397205d52613cc305dc6baff1cbbda1 /tests/test_account.py | |
parent | c6f1196ddc1899e64d60b102e1cfa1c1c1321e77 (diff) | |
parent | d87ada3d73de69ba371acaeca55751e2410c3786 (diff) | |
download | mastodon.py-7e3a4a17a28f52b186e6453a0d1f43614f110b4b.tar.gz |
Merge pull request #113 from codl/more-tests
More tests!
Diffstat (limited to 'tests/test_account.py')
-rw-r--r-- | tests/test_account.py | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/tests/test_account.py b/tests/test_account.py new file mode 100644 index 0000000..dac65ac --- /dev/null +++ b/tests/test_account.py | |||
@@ -0,0 +1,96 @@ | |||
1 | import pytest | ||
2 | from mastodon.Mastodon import MastodonAPIError | ||
3 | |||
4 | @pytest.mark.vcr() | ||
5 | def test_account(api): | ||
6 | account = api.account(1) | ||
7 | assert account | ||
8 | |||
9 | |||
10 | @pytest.mark.vcr() | ||
11 | def test_account_following(api): | ||
12 | following = api.account_following(1) | ||
13 | assert isinstance(following, list) | ||
14 | |||
15 | |||
16 | @pytest.mark.vcr() | ||
17 | def test_account_followers(api): | ||
18 | followers = api.account_followers(1) | ||
19 | assert isinstance(followers, list) | ||
20 | |||
21 | |||
22 | @pytest.mark.vcr() | ||
23 | def test_account_relationships(api): | ||
24 | relationships = api.account_relationships(1) | ||
25 | assert isinstance(relationships, list) | ||
26 | assert len(relationships) == 1 | ||
27 | |||
28 | |||
29 | @pytest.mark.vcr() | ||
30 | def test_account_search(api): | ||
31 | results = api.account_search('admin') | ||
32 | assert isinstance(results, list) | ||
33 | |||
34 | |||
35 | @pytest.mark.vcr() | ||
36 | def test_account_follow_unfollow(api): | ||
37 | relationship = api.account_follow(1) | ||
38 | try: | ||
39 | assert relationship | ||
40 | assert relationship['following'] | ||
41 | finally: | ||
42 | relationship = api.account_unfollow(1) | ||
43 | assert relationship | ||
44 | assert not relationship['following'] | ||
45 | |||
46 | |||
47 | @pytest.mark.vcr() | ||
48 | def test_account_block_unblock(api): | ||
49 | relationship = api.account_block(1) | ||
50 | try: | ||
51 | assert relationship | ||
52 | assert relationship['blocking'] | ||
53 | finally: | ||
54 | relationship = api.account_unblock(1) | ||
55 | assert relationship | ||
56 | assert not relationship['blocking'] | ||
57 | |||
58 | |||
59 | @pytest.mark.vcr() | ||
60 | def test_account_mute_unmute(api): | ||
61 | relationship = api.account_mute(1) | ||
62 | try: | ||
63 | assert relationship | ||
64 | assert relationship['muting'] | ||
65 | finally: | ||
66 | relationship = api.account_unmute(1) | ||
67 | assert relationship | ||
68 | assert not relationship['muting'] | ||
69 | |||
70 | |||
71 | @pytest.mark.vcr() | ||
72 | def test_mutes(api): | ||
73 | mutes = api.mutes() | ||
74 | assert isinstance(mutes, list) | ||
75 | |||
76 | |||
77 | @pytest.mark.vcr() | ||
78 | def test_blocks(api): | ||
79 | blocks = api.blocks() | ||
80 | assert isinstance(blocks, list) | ||
81 | |||
82 | |||
83 | @pytest.mark.vcr() | ||
84 | def test_account_update_credentials(api): | ||
85 | import base64 | ||
86 | with open('tests/image.jpg', 'rb') as f: | ||
87 | image = f.read() | ||
88 | b64_image = base64.b64encode(image) | ||
89 | data_uri = b'data:image/jpeg;base64,' + b64_image | ||
90 | |||
91 | account = api.account_update_credentials( | ||
92 | display_name='John Lennon', | ||
93 | note='I walk funny', | ||
94 | avatar = data_uri, | ||
95 | header = data_uri) | ||
96 | assert account | ||