diff options
author | Lorenz Diener <[email protected]> | 2019-04-27 17:17:08 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2019-04-27 17:17:08 +0200 |
commit | 450ebd983f0d71fed9bf6d874028d8adcc20992e (patch) | |
tree | 1c1a0b4ffea4227eb8b8964a10c36a9144441ad6 /tests | |
parent | 8b8626978752baf14347498640b2319db832145e (diff) | |
parent | e594bad9bb5c459862e7837b42b471d9e5937b6c (diff) | |
download | mastodon.py-450ebd983f0d71fed9bf6d874028d8adcc20992e.tar.gz |
Merge pull request #162 from codl/160
better handling of non-standard error responses, such as from pleroma
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_errors.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/test_errors.py b/tests/test_errors.py new file mode 100644 index 0000000..7329507 --- /dev/null +++ b/tests/test_errors.py | |||
@@ -0,0 +1,20 @@ | |||
1 | import pytest | ||
2 | from mastodon.Mastodon import MastodonAPIError | ||
3 | |||
4 | try: | ||
5 | from mock import MagicMock | ||
6 | except ImportError: | ||
7 | from unittest.mock import MagicMock | ||
8 | |||
9 | def test_nonstandard_errors(api): | ||
10 | response = MagicMock() | ||
11 | response.json = MagicMock(return_value= | ||
12 | "I am a non-standard instance and this error is a plain string.") | ||
13 | response.ok = False | ||
14 | session = MagicMock() | ||
15 | session.request = MagicMock(return_value=response) | ||
16 | |||
17 | api.session = session | ||
18 | with pytest.raises(MastodonAPIError): | ||
19 | api.instance() | ||
20 | |||