aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhalcy <halcy@ARARAGI-KUN>2022-11-25 01:48:49 +0200
committerhalcy <halcy@ARARAGI-KUN>2022-11-25 01:48:49 +0200
commit4be050d3d7116f08d0a1788fc97cd1e2beb9443b (patch)
tree4efeea52b5bb1153043656b53c53ab43e7480b67 /tests/test_errors.py
parent89678e05656c149e2e79d8ab09721059724fa8a0 (diff)
downloadmastodon.py-4be050d3d7116f08d0a1788fc97cd1e2beb9443b.tar.gz
add lang parameter
Diffstat (limited to 'tests/test_errors.py')
-rw-r--r--tests/test_errors.py25
1 files changed, 23 insertions, 2 deletions
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 @@
1import pytest 1import pytest
2import vcr
2from mastodon.Mastodon import MastodonAPIError 3from mastodon.Mastodon import MastodonAPIError
4import json
3 5
4try: 6try:
5 from mock import MagicMock 7 from mock import MagicMock
@@ -8,8 +10,7 @@ except ImportError:
8 10
9def test_nonstandard_errors(api): 11def test_nonstandard_errors(api):
10 response = MagicMock() 12 response = MagicMock()
11 response.json = MagicMock(return_value= 13 response.json = MagicMock(return_value="I am a non-standard instance and this error is a plain string.")
12 "I am a non-standard instance and this error is a plain string.")
13 response.ok = False 14 response.ok = False
14 response.status_code = 501 15 response.status_code = 501
15 session = MagicMock() 16 session = MagicMock()
@@ -19,3 +20,23 @@ def test_nonstandard_errors(api):
19 with pytest.raises(MastodonAPIError): 20 with pytest.raises(MastodonAPIError):
20 api.instance() 21 api.instance()
21 22
23@pytest.mark.vcr()
24def test_lang_for_errors(api):
25 try:
26 api.status_post("look at me i am funny shark gawr gura: " + "a" * 50000)
27 except Exception as e:
28 e1 = str(e)
29 api.set_language("de")
30 try:
31 api.status_post("look at me i am funny shark gawr gura: " + "a" * 50000)
32 except Exception as e:
33 e2 = str(e)
34 assert e1 != e2
35
36def test_broken_date(api):
37 dict1 = json.loads('{"uri":"icosahedron.website", "created_at": "", "edited_at": "2012-09-27"}', object_hook=api._Mastodon__json_hooks)
38 dict2 = json.loads('{"uri":"icosahedron.website", "created_at": "2012-09-27", "subfield": {"edited_at": "null"}}', object_hook=api._Mastodon__json_hooks)
39 assert "edited_at" in dict1
40 assert not "created_at" in dict1
41 assert "created_at" in dict2
42 assert not "edited_at" in dict2.subfield
Powered by cgit v1.2.3 (git 2.41.0)