diff options
Diffstat (limited to 'test/python')
| -rw-r--r-- | test/python/test_openapi.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/python/test_openapi.py b/test/python/test_openapi.py new file mode 100644 index 0000000..03100b9 --- /dev/null +++ b/test/python/test_openapi.py @@ -0,0 +1,28 @@ +"""Mirrors tests/openapi.rs.""" + +import http.client +import json +import unittest + +from server_test_case import HOST, PORT, ServerTestCase + + +class OpenApiTest(ServerTestCase): + def test_openapi_json_describes_all_endpoints(self): + conn = http.client.HTTPConnection(HOST, int(PORT), timeout=5) + try: + conn.request("GET", "/openapi.json") + response = conn.getresponse() + body = response.read() + finally: + conn.close() + self.assertEqual(response.status, 200) + + doc = json.loads(body) + self.assertEqual(doc["info"]["title"], "GeneNetwork4 API") + for path in ("/", "/version", "/species"): + self.assertIn(path, doc["paths"]) + + +if __name__ == "__main__": + unittest.main() |
