From 4be050d3d7116f08d0a1788fc97cd1e2beb9443b Mon Sep 17 00:00:00 2001 From: halcy Date: Fri, 25 Nov 2022 01:48:49 +0200 Subject: add lang parameter --- tests/test_errors.py | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'tests/test_errors.py') diff --git a/tests/test_errors.py b/tests/test_errors.py index 5c13d04..ca11c42 100644 --- a/tests/test_errors.py +++ b/tests/test_errors.py @@ -1,5 +1,7 @@ import pytest +import vcr from mastodon.Mastodon import MastodonAPIError +import json try: from mock import MagicMock @@ -8,8 +10,7 @@ except ImportError: def test_nonstandard_errors(api): response = MagicMock() - response.json = MagicMock(return_value= - "I am a non-standard instance and this error is a plain string.") + response.json = MagicMock(return_value="I am a non-standard instance and this error is a plain string.") response.ok = False response.status_code = 501 session = MagicMock() @@ -19,3 +20,23 @@ def test_nonstandard_errors(api): with pytest.raises(MastodonAPIError): api.instance() +@pytest.mark.vcr() +def test_lang_for_errors(api): + try: + api.status_post("look at me i am funny shark gawr gura: " + "a" * 50000) + except Exception as e: + e1 = str(e) + api.set_language("de") + try: + api.status_post("look at me i am funny shark gawr gura: " + "a" * 50000) + except Exception as e: + e2 = str(e) + assert e1 != e2 + +def test_broken_date(api): + dict1 = json.loads('{"uri":"icosahedron.website", "created_at": "", "edited_at": "2012-09-27"}', object_hook=api._Mastodon__json_hooks) + dict2 = json.loads('{"uri":"icosahedron.website", "created_at": "2012-09-27", "subfield": {"edited_at": "null"}}', object_hook=api._Mastodon__json_hooks) + assert "edited_at" in dict1 + assert not "created_at" in dict1 + assert "created_at" in dict2 + assert not "edited_at" in dict2.subfield -- cgit v1.2.3