diff options
author | Alexander Kabui | 2021-05-03 10:11:05 +0300 |
---|---|---|
committer | Alexander Kabui | 2021-05-03 10:11:05 +0300 |
commit | a1b1fdce9c92fd84e97310c79c17e7b1c74bff07 (patch) | |
tree | c757f767bf07547b09a4bbc7060aea5a9cc36679 /tests/unit/computations | |
parent | d7aa112eff101feb98755a05ddfa2870aa0f27b0 (diff) | |
download | genenetwork3-a1b1fdce9c92fd84e97310c79c17e7b1c74bff07.tar.gz |
replace database with conn
Diffstat (limited to 'tests/unit/computations')
-rw-r--r-- | tests/unit/computations/test_correlation.py | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/tests/unit/computations/test_correlation.py b/tests/unit/computations/test_correlation.py index 8bb5cd1..c6fa35e 100644 --- a/tests/unit/computations/test_correlation.py +++ b/tests/unit/computations/test_correlation.py @@ -104,7 +104,7 @@ class TestCorrelation(TestCase): results = do_bicor(x_val=[1, 2, 3], y_val=[4, 5, 6]) - self.assertEqual(results, ([1, 2, 3], [4, 5, 6]) + self.assertEqual(results, (0.0, 0.0) ) @mock.patch("gn3.computations.correlations.compute_corr_coeff_p_value") @@ -291,10 +291,10 @@ class TestCorrelation(TestCase): expected_db_results = [namedtuple("lit_coeff", "val")(x*0.1) for x in range(1, 4)] - database_instance = DataBase(expected_results=expected_db_results) + conn = DataBase(expected_results=expected_db_results) expected_results = ("1", 0.1) - lit_results = fetch_lit_correlation_data(conn=database_instance, + lit_results = fetch_lit_correlation_data(conn=conn, gene_id="1", input_mouse_gene_id="20", mouse_gene_id="15") @@ -305,11 +305,11 @@ class TestCorrelation(TestCase): """Test that corr coeffient returned is 0 given the\ db value if corr coefficient is empty """ - database_instance = mock.Mock() - database_instance.cursor.return_value = DataBase() - database_instance.execute.return_value.fetchone.return_value = None + conn = mock.Mock() + conn.cursor.return_value = DataBase() + conn.execute.return_value.fetchone.return_value = None - lit_results = fetch_lit_correlation_data(conn=database_instance, + lit_results = fetch_lit_correlation_data(conn=conn, input_mouse_gene_id="12", gene_id="16", mouse_gene_id="12") @@ -356,7 +356,7 @@ class TestCorrelation(TestCase): """Test for converting a gene id to mouse geneid\ given a species which is not mouse """ - database_instance = mock.Mock() + conn = mock.Mock() test_data = [("Human", 14), (None, 9), ("Mouse", 15), ("Rat", 14)] database_results = [namedtuple("mouse_id", "mouse")(val) @@ -365,12 +365,12 @@ class TestCorrelation(TestCase): cursor = mock.Mock() cursor.execute.return_value = 1 cursor.fetchone.side_effect = database_results - database_instance.cursor.return_value = cursor + conn.cursor.return_value = cursor expected_results = [12, None, 13, 14] for (species, gene_id) in test_data: mouse_gene_id_results = map_to_mouse_gene_id( - conn=database_instance, species=species, gene_id=gene_id) + conn=conn, species=species, gene_id=gene_id) results.append(mouse_gene_id_results) self.assertEqual(results, expected_results) @@ -382,7 +382,7 @@ class TestCorrelation(TestCase): and is used in the api/correlation/lit """ - database = mock.Mock() + conn = mock.Mock() expected_mocked_lit_results = [{"1412_at": {"gene_id": 11, "lit_corr": 0.9}}, {"1412_a": { "gene_id": 17, "lit_corr": 0.48}}] @@ -390,7 +390,7 @@ class TestCorrelation(TestCase): mock_lit_corr.return_value = expected_mocked_lit_results lit_correlation_results = compute_all_lit_correlation( - conn=database, trait_lists=[("1412_at", 11), ("1412_a", 121)], + conn=conn, trait_lists=[("1412_at", 11), ("1412_a", 121)], species="rat", gene_id=12) self.assertEqual(lit_correlation_results, expected_mocked_lit_results) |