aboutsummaryrefslogtreecommitdiff
path: root/wqflask/tests/unit
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-09-22 06:33:47 +0300
committerFrederick Muriuki Muriithi2022-09-22 06:33:47 +0300
commit30f305c1b87b4b6c4f308b15d5ae9248dc367e14 (patch)
treec5eb6fa62ccb63740a006bf3029cbd9cce140dcb /wqflask/tests/unit
parentd4f00edc48e4b0b467440cb7566f26920be99d95 (diff)
downloadgenenetwork2-30f305c1b87b4b6c4f308b15d5ae9248dc367e14.tar.gz
Provide database cursor as argument for TheSpecies and Chromosomes
Provide the database cursor as an argument to the methods of the two classes: * wqflask.base.species.TheSpecies * wqflask.base.species.Chromosomes Also update dependent code to initialise and pass the cursor where these classes are used.
Diffstat (limited to 'wqflask/tests/unit')
-rw-r--r--wqflask/tests/unit/base/test_species.py20
1 files changed, 8 insertions, 12 deletions
diff --git a/wqflask/tests/unit/base/test_species.py b/wqflask/tests/unit/base/test_species.py
index d7ba30a3..f12bde6d 100644
--- a/wqflask/tests/unit/base/test_species.py
+++ b/wqflask/tests/unit/base/test_species.py
@@ -30,17 +30,14 @@ class MockDataset:
(None, "Random Dataset", None, 1)))
def test_species(mocker, species_name, dataset,
expected_name, chromosome_param):
- mock_conn = mocker.patch("base.species.database_connection")
- mock_conn.return_value.__enter__.return_value = mocker.MagicMock()
_c = mocker.patch("base.species.Chromosomes",
return_value=chromosome_param)
- with mock_conn() as conn:
- test_species = TheSpecies(dataset=dataset,
- species_name=species_name)
- _c.assert_called_with(conn=conn, species=species_name,
- dataset=dataset)
- assert test_species.name == expected_name
- assert test_species.chromosomes == chromosome_param
+ test_species = TheSpecies(dataset=dataset,
+ species_name=species_name)
+ _c.assert_called_with(species=species_name,
+ dataset=dataset)
+ assert test_species.name == expected_name
+ assert test_species.chromosomes == chromosome_param
@pytest.mark.parametrize(
@@ -74,9 +71,8 @@ def test_create_chromosomes(mocker, species, dataset, expected_call):
cursor.fetchall.return_value = (("1", 2, 10,),
("2", 3, 11,),
("4", 5, 15,),)
- _c = Chromosomes(conn=mock_conn,
- dataset=dataset, species=species)
- assert _c.chromosomes == OrderedDict([
+ _c = Chromosomes(dataset=dataset, species=species)
+ assert _c.chromosomes(cursor) == OrderedDict([
("1", IndChromosome("1", 10)),
("2", IndChromosome("2", 11)),
("4", IndChromosome("4", 15)),