Fix test_legacy_api.py
Or rather, reimplement one of Berker's fixes and add one of mine: - add back the http_auth_headers fix Berker wrote - decode to json when testing the response.body, since we have no idea what the order will be here
This commit is contained in:
parent
3a02813c7a
commit
58a7292fed
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
import base64
|
import base64
|
||||||
|
import json
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
@ -48,10 +49,10 @@ class TestAPI(object):
|
|||||||
return template.TEMPLATE_TEST_CONTEXT[template_name]
|
return template.TEMPLATE_TEST_CONTEXT[template_name]
|
||||||
|
|
||||||
def http_auth_headers(self):
|
def http_auth_headers(self):
|
||||||
return {'Authorization': 'Basic {0}'.format(
|
return {'Authorization': ('Basic {0}'.format(
|
||||||
base64.b64encode(':'.join([
|
base64.b64encode((':'.join([
|
||||||
self.user.username,
|
self.user.username,
|
||||||
self.user_password])))}
|
self.user_password])).encode('ascii')).decode()))}
|
||||||
|
|
||||||
def do_post(self, data, test_app, **kwargs):
|
def do_post(self, data, test_app, **kwargs):
|
||||||
url = kwargs.pop('url', '/api/submit')
|
url = kwargs.pop('url', '/api/submit')
|
||||||
@ -77,8 +78,8 @@ class TestAPI(object):
|
|||||||
'/api/test',
|
'/api/test',
|
||||||
headers=self.http_auth_headers())
|
headers=self.http_auth_headers())
|
||||||
|
|
||||||
assert response.body == \
|
assert json.loads(response.body) == {
|
||||||
'{"username": "joapi", "email": "joapi@example.com"}'
|
"username": "joapi", "email": "joapi@example.com"}
|
||||||
|
|
||||||
def test_2_test_submission(self, test_app):
|
def test_2_test_submission(self, test_app):
|
||||||
self.login(test_app)
|
self.login(test_app)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user