diff options
author | Alexander Kabui | 2021-04-12 09:54:12 +0300 |
---|---|---|
committer | GitHub | 2021-04-12 09:54:12 +0300 |
commit | 31ac939f58bf7b6d353ced995ca395376203b25f (patch) | |
tree | 41770a0e4ec3441045fca9bc48de794e444b80ba /tests/integration | |
parent | 5151987063eab58b10a2dd8e831ec036df217531 (diff) | |
download | genenetwork3-31ac939f58bf7b6d353ced995ca395376203b25f.tar.gz |
Integrate correlation API
- add new api for gn2-gn3 sample r integration
- delete map for sample list to values
- add db util file
- add python msql-client dependency
- add db for fetching lit correlation results
- add unittests for db utils
- add tests for db_utils
- modify api for fetching lit correlation results
- refactor Mock Database Connector and unittests
- add sql url parser
- add SQL URI env variable
- refactor code for db utils
- modify return data for lit correlation
- refactor tissue correlation endpoint
- replace db_instance with conn
Diffstat (limited to 'tests/integration')
-rw-r--r-- | tests/integration/test_correlation.py | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/tests/integration/test_correlation.py b/tests/integration/test_correlation.py index 488a8a4..e67f58d 100644 --- a/tests/integration/test_correlation.py +++ b/tests/integration/test_correlation.py @@ -10,10 +10,6 @@ class CorrelationIntegrationTest(TestCase): def setUp(self): self.app = create_app().test_client() - def test_fail(self): - """initial method for class that fails""" - self.assertEqual(2, 2) - @mock.patch("gn3.api.correlation.compute_all_sample_correlation") def test_sample_r_correlation(self, mock_compute_samples): """Test /api/correlation/sample_r/{method}""" @@ -66,13 +62,17 @@ class CorrelationIntegrationTest(TestCase): self.assertEqual(response.get_json(), api_response) @mock.patch("gn3.api.correlation.compute_all_lit_correlation") - def test_lit_correlation(self, mock_compute_corr): + @mock.patch("gn3.api.correlation.database_connector") + def test_lit_correlation(self, database_connector, mock_compute_corr): """Test api/correlation/lit_corr/{species}/{gene_id}""" mock_compute_corr.return_value = [] - post_data = [{"gene_id": 8, "lit_corr": 1}, { - "gene_id": 12, "lit_corr": 0.3}] + database_connector.return_value = (mock.Mock(), mock.Mock()) + + post_data = {"1426678_at": "68031", + "1426679_at": "68036", + "1426680_at": "74777"} response = self.app.post( "/api/correlation/lit_corr/mouse/16", json=post_data, follow_redirects=True) @@ -85,13 +85,20 @@ class CorrelationIntegrationTest(TestCase): """Test api/correlation/tissue_corr/{corr_method}""" mock_tissue_corr.return_value = {} + target_trait_symbol_dict = { + "1418702_a_at": "Bxdc1", "1412_at": "Bxdc2"} + symbol_tissue_dict = { + "bxdc1": [12, 21.1, 11.4, 16.7], "bxdc2": [12, 20.1, 12.4, 1.1]} + primary_dict = {"trait_id": "1449593_at", "tissue_values": [1, 2, 3]} - target_tissue_dict_list = [ - {"trait_id": "1449593_at", "tissue_values": [1, 2, 3]}] + target_tissue_data = { + "trait_symbol_dict": target_trait_symbol_dict, + "symbol_tissue_vals_dict": symbol_tissue_dict + } tissue_corr_input_data = {"primary_tissue": primary_dict, - "target_tissues": target_tissue_dict_list} + "target_tissues_dict": target_tissue_data} response = self.app.post("/api/correlation/tissue_corr/spearman", json=tissue_corr_input_data, follow_redirects=True) |