ga4gh-server
ga4gh-server copied to clipboard
Update protocol errors tests.
Update `tests/unit/test_protocol_errors.pyto test all search endpoints. Run the tests using
nosetests -vs tests/unit/test_protocol_errors.py``.
- Remove the TODO comment, and the check requestClass being in the set of supported methods. (Ignore comment about turning protocol.postMethods into a function).
- Add a new test to check each search endpoint for InvalidJson. Sending malformed JSON like "[}" should result in an
exceptions.MalformedJsonException
. - Add a new test to check that sending a POST request to some suffixes of the valid search URLs will fail with an
exceptions.PathNotFoundException
(e.g. "/reads/search/xyz" should fail). - Add a new test to send requests in which the mimetype is not "application/json", and verify that these return
exceptions.UnsupportedMediaTypeException
- Add a new test to check that sending a GET request to the valid POST URLs results in a exceptions.MethodNotAllowedException.
- More? There's lots of room to add tests here, as it's a good framework to work in. Go through the code in
ga4gh/exceptions.py
,ga4gh/frontend.py
andga4gh/backend.py
and see what general exceptions can be provoked. Add tests for these here if they haven't already been covered.
In action here: https://github.com/ga4gh/server/blob/1b1df9809ebe9a9bc6281a00de6ded9f90d43268/ga4gh/frontend.py#L829