Files
notifications-admin/app/main/views
Ben Thorner 52a5da4d17 Handle exception is org name already exists
Previously this would return a 500 error, as the 400 exception was
not handled from the API [1]. Note that:

- We tend to rely on exception messages to identify the error that
occurred [2][3], with services being a notable deviation [4]. I've
used the exception message approach, as this is more granular and
broadly consistent with the rest of the app.

- There is already code to cover this scenario when a user changes
the name of an existing organisation or service, but the mechanism
is different [5][6]. It makes sense to just get any error from the
call to try and create the organisation.

- The API mock is based on one for services [7], but I've chosen to
have it inline with the test, since we're unlikely to reuse it, and
it's clearer to have the test setup as part of the test.

[1]: https://github.com/alphagov/notifications-api/blob/8f99da525dad3bf653a4e1f9e4a7b7b689219d78/app/organisation/rest.py#L34-L47
[2]: https://github.com/alphagov/notifications-admin/blob/70b606a2d4cb03f2bd9f3a5742a40970a928e696/app/main/views/manage_users.py#L166
[3]: https://github.com/alphagov/notifications-admin/blob/70b606a2d4cb03f2bd9f3a5742a40970a928e696/app/main/views/templates.py#L499
[4]: https://github.com/alphagov/notifications-admin/blob/70b606a2d4cb03f2bd9f3a5742a40970a928e696/app/main/views/add_service.py#L30
[5]: https://github.com/alphagov/notifications-admin/blob/70b606a2d4cb03f2bd9f3a5742a40970a928e696/app/main/views/service_settings.py#L102-L104
[6]: https://github.com/alphagov/notifications-admin/blob/70b606a2d4cb03f2bd9f3a5742a40970a928e696/app/main/views/organisations.py#L264-L266
[7]: https://github.com/alphagov/notifications-admin/blob/0abc143147c98ac50c059729eb5c1a4755d607fa/tests/conftest.py#L590-L606
2021-02-17 09:34:30 +00:00
..
2021-02-16 14:46:13 +00:00
2020-10-09 12:39:22 +01:00
2020-10-02 14:44:17 +01:00