From e2eb510f8708d441accf205b02175b42e501f180 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Sun, 19 Jan 2020 19:32:30 +0100 Subject: [PATCH] python3: update maarch tests (#39092) --- tests/test_source_maarch.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/test_source_maarch.py b/tests/test_source_maarch.py index 85fc0ed..2d908d4 100644 --- a/tests/test_source_maarch.py +++ b/tests/test_source_maarch.py @@ -19,6 +19,7 @@ import json import pytest from django.contrib.auth.models import User +from django.utils.encoding import force_text from httmock import urlmatch, HTTMock @@ -56,6 +57,7 @@ class MaarchMock(BaseMock): 'headers': { 'content-type': 'application/json', }, + 'status_code': 200, } list_endpoint.path = '^/rest/res/list$' @@ -71,6 +73,7 @@ class MaarchMock(BaseMock): 'headers': { 'content-type': 'application/json', }, + 'status_code': 200, } update_status.path = '^/rest/res/resource/status$' @@ -152,7 +155,7 @@ def test_utils(maarch): assert welco_maarch_obj.grc_refused_status == 'GRCREFUSED' -PDF_MOCK = '%PDF-1.4 ...' +PDF_MOCK = b'%PDF-1.4 ...' def test_feed(settings, app, maarch, wcs, user): @@ -173,7 +176,7 @@ def test_feed(settings, app, maarch, wcs, user): 'resources': [ { 'res_id': 1, - 'fileBase64Content': base64.b64encode(PDF_MOCK), + 'fileBase64Content': force_text(base64.b64encode(PDF_MOCK)), } ], }) @@ -250,7 +253,7 @@ def test_feed(settings, app, maarch, wcs, user): user.set_password('test') user.save() # verify authentication error - response = app.post_json('/api/mail/response/', params={}, status=403) + response = app.post_json('/api/mail/response/', params={}, status=(401, 403)) app.authorization = ('Basic', ('test', 'test')) # verify serializer error response = app.post_json('/api/mail/response/', params={}, status=400)