diff options
author | BonfaceKilz | 2021-05-20 21:26:34 +0300 |
---|---|---|
committer | zsloan | 2021-06-18 22:08:04 +0000 |
commit | 786d48ede007f0134081495f3f63be3a33b8f71e (patch) | |
tree | a6057fd606d634c02343313121181d96493963e8 /tests/unit/db | |
parent | 2face963fcba5b3231e9cc26a38f1370b00eb7b0 (diff) | |
download | genenetwork3-786d48ede007f0134081495f3f63be3a33b8f71e.tar.gz |
tests: test_phenotype: Add function that tests "fetchone"
Diffstat (limited to 'tests/unit/db')
-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'") |