I have faced the below error while testing an API.
AppError: Bad response: 404 Not Found (not 200 OK or 3xx redirect for http://localhost/_ah/spi/AdminAuthentication.authenticate)
'{"state": "APPLICATION_ERROR", "error_message": "No user with the E-mail address \\"[email protected]\\" exists."}'
Here is the test function, I wrote
def test_should_not_authenticate_if_there_is_no_user_for_email(self):
app = endpoints.api_server([AdminAuthentication], restricted=False)
testapp = webtest.TestApp(app)
msg = {'email': '[email protected]'}
resp = testapp.post_json('/_ah/spi/AdminAuthentication.authenticate', msg)
self.assertEqual(resp.status_int, 404)
corresponding routing definition of app.yaml
file should look like,
- url: /_ah/spi/.*
script: api.services.application
By default it's expecting status code 200. http://webtest.readthedocs.org/en/latest/testapp.html
To indicate another status is expected, use the keyword argument status=404 to (for example) check that it is a 404 status, or status="*" to allow any status, or status="400 Custom Bad Request" to use custom reason phrase. If you expect errors to be printed, use expect_errors=True.