1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
"""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",
"/species/{species}",
"/groups",
"/groups/{group}",
"/groups/{group}/strains",
"/groups/{group}/traits/{trait_id}",
"/groups/{group}/traits/{trait_id}/values",
"/groups/{group}/datasets",
"/datasets/{dataset}",
"/datasets/{dataset}/probesets/{probeset}",
"/datasets/{dataset}/probesets/{probeset}/values",
):
self.assertIn(path, doc["paths"])
if __name__ == "__main__":
unittest.main()
|