aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcodl <[email protected]>2017-11-30 00:56:35 +0100
committercodl <[email protected]>2017-11-30 00:56:35 +0100
commitf9a52029fc6d399c8fcd85a50060e0f5773da78e (patch)
treeb11bf113ab1bc6bd7ad57a5bed341b2243634a29 /tests/test_account.py
parent7464315be7c4a2790c83d1528f8d372ce15f0290 (diff)
downloadmastodon.py-f9a52029fc6d399c8fcd85a50060e0f5773da78e.tar.gz
add tests for account methods
Diffstat (limited to 'tests/test_account.py')
-rw-r--r--tests/test_account.py84
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 @@
1import pytest
2from mastodon.Mastodon import MastodonAPIError
3
4@pytest.mark.vcr()
5def test_account(api):
6 account = api.account(1)
7 assert account
8
9
10@pytest.mark.vcr()
11def test_account_following(api):
12 following = api.account_following(1)
13 assert isinstance(following, list)
14
15
16@pytest.mark.vcr()
17def test_account_followers(api):
18 followers = api.account_followers(1)
19 assert isinstance(followers, list)
20
21
22@pytest.mark.vcr()
23def 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()
30def test_account_search(api):
31 results = api.account_search('admin')
32 assert isinstance(results, list)
33
34
35@pytest.mark.vcr()
36def 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()
48def 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()
60def 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()
72def 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
Powered by cgit v1.2.3 (git 2.41.0)