Merge pull request #112 from codl/fix-111

fix #111
This commit is contained in:
Lorenz Diener 2017-11-30 16:02:29 +01:00 cometido por GitHub
commit c6f1196ddc
No se encontró ninguna clave conocida en la base de datos para esta firma
ID de clave GPG: 4AEE18F83AFDEB23
S'han modificat 3 arxius amb 38 adicions i 2 eliminacions

Veure arxiu

@ -1227,7 +1227,9 @@ class Mastodon:
# See if the returned dict is an error dict even though status is 200
if isinstance(response, dict) and 'error' in response:
raise MastodonAPIError("Mastodon API returned error: " + str(response['error']))
if not isinstance(response['error'], six.string_types):
response['error'] = six.text_type(response['error'])
raise MastodonAPIError("Mastodon API returned error: " + response['error'])
# Parse link headers
if isinstance(response, list) and \

Veure arxiu

@ -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

Veure arxiu

@ -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):