From 77a55f3cfe70dfbe319c28380eb16a4f9516366c Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Mon, 3 Aug 2020 16:47:42 +0300 Subject: Add extra test for "build_datasets" * wqflask/tests/api/test_gen_menu.py: Add test. --- wqflask/tests/api/test_gen_menu.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'wqflask/tests/api/test_gen_menu.py') diff --git a/wqflask/tests/api/test_gen_menu.py b/wqflask/tests/api/test_gen_menu.py index ca841708..4a928d12 100644 --- a/wqflask/tests/api/test_gen_menu.py +++ b/wqflask/tests/api/test_gen_menu.py @@ -178,6 +178,25 @@ class TestGenMenu(unittest.TestCase): self.assertEqual(build_datasets("Mouse", "MDP", "Phenotypes"), [["None", "BXDPublish", "Mouse Phenome Database"]]) + @mock.patch('wqflask.api.gen_menu.g') + def test_build_datasets_with_type_phenotypes_and_no_results(self, db_mock): + """Test that correct dataset is returned for a phenotype type with no + results + + """ + db_mock.db.execute.return_value.fetchall.return_value = None + db_mock.db.execute.return_value.fetchone.return_value = (121, + "text value") + self.assertEqual(build_datasets("Mouse", "BXD", "Phenotypes"), + [["None", "121", "text value"]]) + db_mock.db.execute.assert_called_with( + "SELECT PublishFreeze.Name, PublishFreeze.FullName " + "FROM PublishFreeze, InbredSet " + "WHERE InbredSet.Name = 'BXD' AND " + "PublishFreeze.InbredSetId = InbredSet.Id " + "ORDER BY PublishFreeze.CreateTime ASC" + ) + @mock.patch('wqflask.api.gen_menu.g') def test_build_datasets_with_type_genotypes(self, db_mock): """Test that correct dataset is returned for a phenotype type""" -- cgit v1.2.3