def test_render_results(flask_app): """Make sure that we can render a success payload correctly.""" results = {'foo': 'bar'} with flask_app.test_request_context('/'): response = avalon.web.response.render(results=results) assert 'foo'.encode(response.charset) in response.get_data() assert 'bar'.encode(response.charset) in response.get_data()
def test_render_errors(flask_app): """Make sure that we can render errors correctly.""" error = avalon.exc.InvalidParameterNameError( 'Invalid parameter name', param='foo') with flask_app.test_request_context('/'): response = avalon.web.response.render(error=error) assert ('avalon.service.error.invalid_input_name'.encode(response.charset) in response.get_data())