mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-12 22:44:09 -05:00
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]:8f99da525d/app/organisation/rest.py (L34-L47)[2]:70b606a2d4/app/main/views/manage_users.py (L166)[3]:70b606a2d4/app/main/views/templates.py (L499)[4]:70b606a2d4/app/main/views/add_service.py (L30)[5]:70b606a2d4/app/main/views/service_settings.py (L102-L104)[6]:70b606a2d4/app/main/views/organisations.py (L264-L266)[7]:0abc143147/tests/conftest.py (L590-L606)