diff options
Diffstat (limited to 'tests/test_account.py')
-rw-r--r-- | tests/test_account.py | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/tests/test_account.py b/tests/test_account.py index 3befdd5..4936c11 100644 --- a/tests/test_account.py +++ b/tests/test_account.py | |||
@@ -1,5 +1,6 @@ | |||
1 | import pytest | 1 | import pytest |
2 | from mastodon.Mastodon import MastodonAPIError | 2 | from mastodon.Mastodon import MastodonAPIError, MastodonIllegalArgumentError |
3 | import re | ||
3 | 4 | ||
4 | @pytest.mark.vcr() | 5 | @pytest.mark.vcr() |
5 | def test_account(api): | 6 | def test_account(api): |
@@ -86,12 +87,35 @@ def test_account_update_credentials(api): | |||
86 | image = f.read() | 87 | image = f.read() |
87 | 88 | ||
88 | account = api.account_update_credentials( | 89 | account = api.account_update_credentials( |
89 | display_name='John Lennon', | 90 | display_name='John Lennon', |
90 | note='I walk funny', | 91 | note='I walk funny', |
91 | avatar = "tests/image.jpg", | 92 | avatar = "tests/image.jpg", |
92 | header = image, | 93 | header = image, |
93 | header_mime_type = "image/jpeg") | 94 | header_mime_type = "image/jpeg", |
95 | fields = [ | ||
96 | ("bread", "toasty."), | ||
97 | ("lasagna", "no!!!"), | ||
98 | ] | ||
99 | ) | ||
100 | |||
94 | assert account | 101 | assert account |
102 | assert account["display_name"] == 'John Lennon' | ||
103 | assert re.sub("<.*?>", " ", account["note"]).strip() == 'I walk funny' | ||
104 | assert account["fields"][0].name == "bread" | ||
105 | assert account["fields"][0].value == "toasty." | ||
106 | assert account["fields"][1].name == "lasagna" | ||
107 | assert account["fields"][1].value == "no!!!" | ||
108 | |||
109 | @pytest.mark.vcr() | ||
110 | def test_account_update_credentials_too_many_fields(api): | ||
111 | with pytest.raises(MastodonIllegalArgumentError): | ||
112 | api.account_update_credentials(fields = [ | ||
113 | ('a', 'b'), | ||
114 | ('c', 'd'), | ||
115 | ('e', 'f'), | ||
116 | ('g', 'h'), | ||
117 | ('i', 'j'), | ||
118 | ]) | ||
95 | 119 | ||
96 | @pytest.mark.vcr(match_on=['path']) | 120 | @pytest.mark.vcr(match_on=['path']) |
97 | def test_account_update_credentials_no_header(api): | 121 | def test_account_update_credentials_no_header(api): |