diff options
author | BonfaceKilz | 2021-05-20 21:26:34 +0300 |
---|---|---|
committer | BonfaceKilz | 2021-05-20 23:25:59 +0300 |
commit | c595d980b2ad0366143a5339460053bbca18345e (patch) | |
tree | b52ae497d3d7ff291a60a0dec20cae014353ccc2 | |
parent | 9de02a89cf4d134a4b289e5a799e0880c0e5840f (diff) | |
download | genenetwork3-c595d980b2ad0366143a5339460053bbca18345e.tar.gz |
tests: test_phenotype: Add function that tests "fetchone"
-rw-r--r-- | tests/unit/db/test_phenotypes.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/unit/db/test_phenotypes.py b/tests/unit/db/test_phenotypes.py index 6b394d7..9fed524 100644 --- a/tests/unit/db/test_phenotypes.py +++ b/tests/unit/db/test_phenotypes.py @@ -2,6 +2,7 @@ from unittest import TestCase from unittest import mock +from gn3.db.phenotypes import fetchone from gn3.db.phenotypes import Phenotype from gn3.db.phenotypes import update @@ -41,3 +42,24 @@ class TestPhenotypes(TestCase): "'Test Post Pub', Submitter = 'Rob' " "WHERE id = '1'" ) + + def test_fetch_phenotype(self): + """Test that a single phenotype is fetched properly + + """ + db_mock = mock.MagicMock() + with db_mock.cursor() as cursor: + test_data = ( + 35, "Test pre-publication", "Test post-publication", + "Original description A", "cm^2", "pre-abbrev", + "post-abbrev", "LAB001", "R. W.", "R. W.", "R. W." + ) + cursor.fetchone.return_value = test_data + phenotype = fetchone(db_mock, + "Phenotype", + where=Phenotype(id_=35)) + self.assertEqual(phenotype.id_, 35) + self.assertEqual(phenotype.pre_pub_description, + "Test pre-publication") + cursor.execute.assert_called_once_with( + "SELECT * FROM Phenotype WHERE id = '35'") |