From 4d99e9316ea02ded025eee99fb963290218e52d2 Mon Sep 17 00:00:00 2001 From: codl Date: Wed, 29 Nov 2017 22:03:51 +0100 Subject: [PATCH] add failing test case for #111 --- tests/cassettes/test_status_empty.yaml | 29 ++++++++++++++++++++++++++ tests/test_status.py | 7 ++++++- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 tests/cassettes/test_status_empty.yaml diff --git a/tests/cassettes/test_status_empty.yaml b/tests/cassettes/test_status_empty.yaml new file mode 100644 index 0000000..52be5c4 --- /dev/null +++ b/tests/cassettes/test_status_empty.yaml @@ -0,0 +1,29 @@ +interactions: +- request: + body: !!python/unicode status=&visibility= + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] + Connection: [keep-alive] + Content-Length: ['19'] + Content-Type: [application/x-www-form-urlencoded] + User-Agent: [python-requests/2.18.4] + method: POST + uri: http://localhost:3000/api/v1/statuses + response: + body: {string: "{\"error\":\"\u30D0\u30EA\u30C7\u30FC\u30B7\u30E7\u30F3\u306B\u5931\u6557\u3057\u307E\u3057\u305F: + Text\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044\"}"} + headers: + cache-control: [no-cache] + content-length: ['87'] + content-type: [application/json; charset=utf-8] + transfer-encoding: [chunked] + vary: ['Accept-Encoding, Origin'] + x-content-type-options: [nosniff] + x-frame-options: [SAMEORIGIN] + x-request-id: [b28457db-8446-42ac-b5a8-241d0a7434b4] + x-runtime: ['0.109104'] + x-xss-protection: [1; mode=block] + status: {code: 422, message: Unprocessable Entity} +version: 1 diff --git a/tests/test_status.py b/tests/test_status.py index a5b8b3a..0e891bb 100644 --- a/tests/test_status.py +++ b/tests/test_status.py @@ -5,7 +5,12 @@ from time import sleep @pytest.mark.vcr() def test_status(status, api): status2 = api.status(status['id']) - assert status2 == status + assert status2 + +@pytest.mark.vcr() +def test_status_empty(api): + with pytest.raises(MastodonAPIError): + api.status_post('') @pytest.mark.vcr() def test_status_missing(api):