Commit Graph

15 Commits

Author SHA1 Message Date
Chris Hill-Scott
f6d3ce0b6a Fix test for duplicate service name
There is a uniqueness constraint on service `name` and `email_from`.

When you try to insert a row which has _both_ constraints, there is no
guarantee which one the operation will fail on.

This means that, when handling the exception, service `name` is not
reliably available, because sometimes the operation fails on the
`email_from` constraint instead.

This caused the tests to fail non-deterministically because they were
looking for the service `name` in the error message. As a fix, this
commit does two things:

1. Return either the service `name` or `email_from` in the error
   message, depending which is available.

2. Modify the test to pass on _either_ of the two possible error
   messages.

This is not ideal, but I can’t think of a way to maintain the original
behaviour, and have reliably passing tests.
2016-04-26 15:38:20 +01:00
Nicholas Staples
b56e324a4c Working tests and provider stats table.
Fix for tests and import error.

Added tests and updated for code review comments.
2016-04-25 12:20:06 +01:00
Rebecca Law
df6f784f9e - Remove different behaviour for debug mode in errors.py 2016-04-01 14:19:50 +01:00
Nicholas Staples
090babaaeb Added endpoint for removing user from service, all tests passing. 2016-03-22 13:14:23 +00:00
Rebecca Law
b96b226bad Log exception 2016-03-11 15:52:28 +00:00
Rebecca Law
e055590b07 Changed db queries to use one, which throws NoResultFound exception, this exception is dealt with in our error handlers.
Now a lot of the if none checks can be removed.
2016-03-11 12:39:55 +00:00
Rebecca Law
29a7289d1e Use new email validation.
Use logger.exception where it makes sense, not for SqlAlchemy errors as it give too much information away.
2016-03-08 15:47:35 +00:00
Nicholas Staples
16e1ecb134 Working permissions and all tests passing.
Remove print statements.

Fix for review comments.
2016-02-26 15:00:29 +00:00
Rebecca Law
52ab17e718 Fix duplicate name 2016-02-25 15:35:31 +00:00
Rebecca Law
67af351f26 Fix get_users_by_service to return 404 if service does not exist.
Refactored service/rest.py so that all methods are returning a properly formatted error message so that the error message can deal with the response.
Refactoed errors.py to properly format the error message.
2016-02-25 12:11:51 +00:00
Rebecca Law
17d14f291e Refactor user/<user_id>/code into two endpoints.
- Created new endpoint user/<user_id>/sms-code to send the sms verification code to the user.
- Create new endpoirtn user/<user_id>/email-code to send the email verifcation code to the user.
- Marked the old methods, schema, tests with a TODO to be deleted when the admin app is no longer sending messages to /user/<user_id>/code
- Added error handlers for DataError and NoResultFound. Data error catches invalid input errors.
- Added error handler for SqlAlchemyError which catches any other database errors.
- Removed the need for the try catches around the db calls in the user endpoints with the addition of the db error handlers.
- We may want to wrap db excpetions in the dao, if we want the No results found message to be more specific and say no result found for user.
2016-02-19 11:37:35 +00:00
Adam Shimali
4f33b6f406 Wire up error handlers.
Replace some 400s with more appropriate 500s.

DAO methods that cause unexpected exceptions get caught and
logged by errors.py 500 error handler.
2016-02-17 17:04:50 +00:00
Nicholas Staples
d56bb82d1d Code style fix. 2016-02-01 10:25:09 +00:00
Nicholas Staples
47351b2009 Added exception handling for 500 error messages. 2016-02-01 10:19:17 +00:00
Rebecca Law
34693d70af Removed the main package. 2016-01-14 14:28:23 +00:00