diff options
author | codl <[email protected]> | 2017-11-30 00:56:35 +0100 |
---|---|---|
committer | codl <[email protected]> | 2017-11-30 00:56:35 +0100 |
commit | f9a52029fc6d399c8fcd85a50060e0f5773da78e (patch) | |
tree | b11bf113ab1bc6bd7ad57a5bed341b2243634a29 /tests/test_account.py | |
parent | 7464315be7c4a2790c83d1528f8d372ce15f0290 (diff) | |
download | mastodon.py-f9a52029fc6d399c8fcd85a50060e0f5773da78e.tar.gz |
add tests for account methods
Diffstat (limited to 'tests/test_account.py')
-rw-r--r-- | tests/test_account.py | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/tests/test_account.py b/tests/test_account.py new file mode 100644 index 0000000..3c94531 --- /dev/null +++ b/tests/test_account.py | |||
@@ -0,0 +1,84 @@ | |||
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_account_update_credentials(api): | ||
73 | import base64 | ||
74 | with open('tests/image.jpg', 'rb') as f: | ||
75 | image = f.read() | ||
76 | b64_image = base64.b64encode(image) | ||
77 | data_uri = b'data:image/jpeg;base64,' + b64_image | ||
78 | |||
79 | account = api.account_update_credentials( | ||
80 | display_name='John Lennon', | ||
81 | note='I walk funny', | ||
82 | avatar = data_uri, | ||
83 | header = data_uri) | ||
84 | assert account | ||