diff options
author | BonfaceKilz | 2021-03-03 12:04:00 +0300 |
---|---|---|
committer | BonfaceKilz | 2021-03-08 21:09:58 +0300 |
commit | 396aeed35a5925cb03cc1569669b257b8ccb07cb (patch) | |
tree | 38800eb85ad8ad0020e1474450d03ab16814f572 | |
parent | 87a3e2254bdd837e9647c42b9c4ab98e986c5e1d (diff) | |
download | genenetwork3-396aeed35a5925cb03cc1569669b257b8ccb07cb.tar.gz |
Prepend all endpoints with "api"
-rw-r--r-- | gn3/app.py | 4 | ||||
-rw-r--r-- | tests/integration/test_gemma.py | 10 | ||||
-rw-r--r-- | tests/integration/test_general.py | 6 |
3 files changed, 10 insertions, 10 deletions
@@ -25,6 +25,6 @@ def create_app(config: Union[Dict, str, None] = None) -> Flask: app.config.update(config) elif config.endswith(".py"): app.config.from_pyfile(config) - app.register_blueprint(general, url_prefix="/") - app.register_blueprint(gemma, url_prefix="/gemma") + app.register_blueprint(general, url_prefix="/api/") + app.register_blueprint(gemma, url_prefix="/api/gemma") return app diff --git a/tests/integration/test_gemma.py b/tests/integration/test_gemma.py index 5f4e52b..18e3fb0 100644 --- a/tests/integration/test_gemma.py +++ b/tests/integration/test_gemma.py @@ -30,7 +30,7 @@ class GemmaAPITest(unittest.TestCase): def test_get_version(self, mock_run_cmd): """Test that the correct response is returned""" mock_run_cmd.return_value = {"status": 0, "output": "v1.9"} - response = self.app.get("/gemma/version", follow_redirects=True) + response = self.app.get("/api/gemma/version", follow_redirects=True) self.assertEqual(response.get_json(), {"status": 0, "output": "v1.9"}) self.assertEqual(response.status_code, 200) @@ -58,7 +58,7 @@ class GemmaAPITest(unittest.TestCase): "bxd_GWA_gUFhGu4rLG7k+CXLPk1OUg.txt") ] mock_queue_cmd.return_value = "my-unique-id" - response = self.app.post("/gemma/k-gwa-computation", json={ + response = self.app.post("/api/gemma/k-gwa-computation", json={ "trait_filename": "BXD.txt", "geno_filename": "BXD_geno", "values": ["X", "N/A", "X"], @@ -99,7 +99,7 @@ class GemmaAPITest(unittest.TestCase): _redis_conn = MockRedis(redis=mock.MagicMock(), hget=mock.MagicMock()) mock_redis.return_value = _redis_conn mock_queue_cmd.return_value = "my-unique-id" - response = self.app.post("/gemma/k-gwa-computation", json={ + response = self.app.post("/api/gemma/k-gwa-computation", json={ "trait_filename": os.path.abspath(os.path.join( os.path.dirname(__file__), "test_data/" @@ -141,7 +141,7 @@ class GemmaAPITest(unittest.TestCase): mock_hget.return_value = b"test" _redis_conn = MockRedis(redis=mock.MagicMock(), hget=mock_hget) mock_redis.return_value = _redis_conn - response = self.app.get(("/gemma/status/" + response = self.app.get(("/api/gemma/status/" "cmd%3A%3A2021-02-1217-3224-3224-1234"), follow_redirects=True) mock_hget.assert_called_once_with( @@ -170,7 +170,7 @@ class GemmaAPITest(unittest.TestCase): "-p traitfilename.txt " "-a genotype_snps.txt " "-gk > k_output_filename.json") - response = self.app.post("/gemma/k-compute/test-data") + response = self.app.post("/api/gemma/k-compute/test-data") self.assertEqual(response.get_json(), { "output_file": "hash-k-output.json", "status": "queued", diff --git a/tests/integration/test_general.py b/tests/integration/test_general.py index 76cc754..99c4824 100644 --- a/tests/integration/test_general.py +++ b/tests/integration/test_general.py @@ -13,7 +13,7 @@ class GeneralAPITest(unittest.TestCase): def test_metadata_endpoint_exists(self): """Test that /metadata/upload exists""" - response = self.app.post("/metadata/upload/d41d86-e4ceEo") + response = self.app.post("/api/metadata/upload/d41d86-e4ceEo") self.assertEqual(response.status_code, 400) self.assertEqual(response.get_json(), {"status": 128, @@ -29,7 +29,7 @@ class GeneralAPITest(unittest.TestCase): gzip_file = os.path.abspath(os.path.join( os.path.dirname(__file__), "../unit/upload-data.tar.gz")) - response = self.app.post("/metadata/upload/d41d86-e4ceEo", + response = self.app.post("/api/metadata/upload/d41d86-e4ceEo", data={"file": (gzip_file, "upload-data.tar.gz")}) self.assertEqual(response.status_code, 201) @@ -39,7 +39,7 @@ class GeneralAPITest(unittest.TestCase): def test_metadata_file_wrong_upload(self): """Test that incorrect upload return correct status code""" - response = self.app.post("/metadata/upload/d41d86-e4ceEo", + response = self.app.post("/api/metadata/upload/d41d86-e4ceEo", data={"file": (__file__, "my_file")}) self.assertEqual(response.status_code, 500) |