tests: use response.text to check for textual contents

This commit is contained in:
Frédéric Péters 2018-07-26 08:26:27 +02:00
parent bc7ef1ddf3
commit cbd9044835
1 changed files with 3 additions and 3 deletions

View File

@ -439,18 +439,18 @@ def test_post_cell(app):
resp2 = resp.form.submit()
assert urlparse.urlparse(resp2.location).path == '/'
resp2 = resp2.follow()
assert 'Error sending data.' in resp2.content
assert 'Error sending data.' in resp2.text
settings.JSON_CELL_TYPES['test-post-cell']['actions']['create']['error-message'] = 'Failed to create stuff.'
resp2 = resp.form.submit()
assert urlparse.urlparse(resp2.location).path == '/'
resp2 = resp2.follow()
assert 'Failed to create stuff.' in resp2.content
assert 'Failed to create stuff.' in resp2.text
with mock.patch('combo.utils.requests.request') as requests_post:
requests_post.return_value = mock.Mock(content=json.dumps({'err': 0}), status_code=400)
resp2 = resp.form.submit(headers={'x-requested-with': 'XMLHttpRequest'})
assert resp2.content.startswith('<form')
assert resp2.text.startswith('<form')
assert resp2.headers['x-error-message'] == 'Failed to create stuff.'
# check variable substitution in URL