diff options
author | Munyoki Kilyungi | 2024-01-12 17:01:21 +0300 |
---|---|---|
committer | BonfaceKilz | 2024-01-12 17:03:14 +0300 |
commit | 81b82ede3004ee870f8dfe55d5fe23ee86e98137 (patch) | |
tree | 46e97568ab5d3a60a66b37409496b205bdf7b00c /gn2/tests | |
parent | 2418e965209c911dbd6f518c93cbe7d9b602ff1b (diff) | |
download | genenetwork2-81b82ede3004ee870f8dfe55d5fe23ee86e98137.tar.gz |
Correctly patch the db connection when fetching accession_id.
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
Co-authored-by: Alexander Kabui <alexanderkabua@gmail.com>
Diffstat (limited to 'gn2/tests')
-rw-r--r-- | gn2/tests/unit/base/test_data_set.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/gn2/tests/unit/base/test_data_set.py b/gn2/tests/unit/base/test_data_set.py index 9f9fb132..d3d11022 100644 --- a/gn2/tests/unit/base/test_data_set.py +++ b/gn2/tests/unit/base/test_data_set.py @@ -204,13 +204,14 @@ class TestDataSetTypes(unittest.TestCase): class TestDatasetAccessionId(unittest.TestCase): """Tests for the DataSetType class""" - @mock.patch("gn2.base.data_set.dataset.query_sql") + @mock.patch("gn2.base.data_set.dataset.database_connection") @mock.patch("gn2.base.data_set.dataset.DatasetGroup") - def test_get_accession_id(self, mock_dataset_group, mock_query_sql): + def test_get_accession_id(self, mock_dataset_group, conn): def mock_fn(): yield MonadicDict({"accession_id": 7}) mock_dataset_group.return_value = MockGroup() - mock_query_sql.return_value = mock_fn() + conn = mock.MagicMock() + conn.return_value.__enter__ = mock_fn sample_dataset = MockPhenotypeDataset( name="BXD-LongevityPublish", get_samplelist=False, @@ -221,12 +222,13 @@ class TestDatasetAccessionId(unittest.TestCase): .accession_id\ .bind(lambda x: self.assertEqual(7, x)) - @mock.patch("gn2.base.data_set.dataset.query_sql") + @mock.patch("gn2.base.data_set.dataset.database_connection") @mock.patch("gn2.base.data_set.dataset.DatasetGroup") def test_get_accession_id_empty_return(self, mock_dataset_group, - mock_query_sql): + conn): mock_dataset_group.return_value = MockGroup() - mock_query_sql.return_value = None + conn = mock.MagicMock() + conn.return_value.__enter__ = None sample_dataset = MockPhenotypeDataset( name="BXD-LongevityPublish", get_samplelist=False, |