From b55792f2daf648affe52d78c7f3a480f6550dfc8 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Wed, 29 Jul 2020 22:09:21 +0300 Subject: Add initial gen_menu test * wqflask/tests/api/__init__.py: Add it * wqflask/tests/api/test_gen_menu.py: Add test for get_species --- wqflask/tests/api/__init__.py | 0 wqflask/tests/api/test_gen_menu.py | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 wqflask/tests/api/__init__.py create mode 100644 wqflask/tests/api/test_gen_menu.py (limited to 'wqflask/tests/api') diff --git a/wqflask/tests/api/__init__.py b/wqflask/tests/api/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/wqflask/tests/api/test_gen_menu.py b/wqflask/tests/api/test_gen_menu.py new file mode 100644 index 00000000..81908129 --- /dev/null +++ b/wqflask/tests/api/test_gen_menu.py @@ -0,0 +1,19 @@ +"""Test cases for wqflask.api.gen_menu""" +import unittest +import mock + +from wqflask.api.gen_menu import get_species + +class TestGenMenu(unittest.TestCase): + """Tests for the gen_menu module""" + + @mock.patch('wqflask.api.gen_menu.g') + def test_get_species(self, db_mock): + """Test that assertion is raised when dataset and dataset_name are defined""" + db_mock.db.execute.return_value.fetchall.return_value = (('human', 'Human'), + ('mouse', 'Mouse')) + self.assertEqual(get_species(), + [['human', 'Human'], ['mouse', 'Mouse']]) + db_mock.db.execute.assert_called_once_with( + "SELECT Name, MenuName FROM Species ORDER BY OrderId" + ) -- cgit v1.2.3