From 85ca59993582ea54ac5843671d755e5337a2d599 Mon Sep 17 00:00:00 2001 From: Lorenz Diener Date: Tue, 5 Jun 2018 01:54:12 +0200 Subject: Add fields support, tests --- tests/test_account.py | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) (limited to 'tests/test_account.py') 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 @@ import pytest -from mastodon.Mastodon import MastodonAPIError +from mastodon.Mastodon import MastodonAPIError, MastodonIllegalArgumentError +import re @pytest.mark.vcr() def test_account(api): @@ -86,12 +87,35 @@ def test_account_update_credentials(api): image = f.read() account = api.account_update_credentials( - display_name='John Lennon', - note='I walk funny', - avatar = "tests/image.jpg", - header = image, - header_mime_type = "image/jpeg") + display_name='John Lennon', + note='I walk funny', + avatar = "tests/image.jpg", + header = image, + header_mime_type = "image/jpeg", + fields = [ + ("bread", "toasty."), + ("lasagna", "no!!!"), + ] + ) + assert account + assert account["display_name"] == 'John Lennon' + assert re.sub("<.*?>", " ", account["note"]).strip() == 'I walk funny' + assert account["fields"][0].name == "bread" + assert account["fields"][0].value == "toasty." + assert account["fields"][1].name == "lasagna" + assert account["fields"][1].value == "no!!!" + +@pytest.mark.vcr() +def test_account_update_credentials_too_many_fields(api): + with pytest.raises(MastodonIllegalArgumentError): + api.account_update_credentials(fields = [ + ('a', 'b'), + ('c', 'd'), + ('e', 'f'), + ('g', 'h'), + ('i', 'j'), + ]) @pytest.mark.vcr(match_on=['path']) def test_account_update_credentials_no_header(api): -- cgit v1.2.3