diff options
author | BonfaceKilz | 2020-08-03 15:55:32 +0300 |
---|---|---|
committer | BonfaceKilz | 2020-08-03 16:44:49 +0300 |
commit | 899cf35a1dce7ad18645d00238fb39917f8e6e4f (patch) | |
tree | 817b6d037a7ddd01974b4fc0989dfd4c6038c9c7 /wqflask/tests/api | |
parent | 31e582e4d1e3fc2d36a72f9c775bde40ab61d878 (diff) | |
download | genenetwork2-899cf35a1dce7ad18645d00238fb39917f8e6e4f.tar.gz |
Add tests for "get_datasets"
* wqflask/tests/api/test_gen_menu.py: Add new tests
Diffstat (limited to 'wqflask/tests/api')
-rw-r--r-- | wqflask/tests/api/test_gen_menu.py | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/wqflask/tests/api/test_gen_menu.py b/wqflask/tests/api/test_gen_menu.py index 0379e297..a606a300 100644 --- a/wqflask/tests/api/test_gen_menu.py +++ b/wqflask/tests/api/test_gen_menu.py @@ -5,6 +5,7 @@ import mock from wqflask.api.gen_menu import get_species from wqflask.api.gen_menu import get_groups from wqflask.api.gen_menu import get_types +from wqflask.api.gen_menu import get_datasets from wqflask.api.gen_menu import phenotypes_exist from wqflask.api.gen_menu import genotypes_exist from wqflask.api.gen_menu import build_datasets @@ -30,6 +31,41 @@ class TestGenMenu(unittest.TestCase): ] } + self.test_type = { + 'mouse': { + 'H_T2': [('Phenotypes', + 'Traits and Cofactors', + 'Phenotypes'), + ('Genotypes', + 'DNA Markers and SNPs', + 'Genotypes'), + ['M', 'M', 'Molecular Trait Datasets']], + 'H_T1': [('Phenotypes', + 'Traits and Cofactors', + 'Phenotypes'), + ('Genotypes', + 'DNA Markers and SNPs', + 'Genotypes'), + ['M', 'M', 'Molecular Trait Datasets']] + }, + 'human': { + 'HLC': [('Phenotypes', + 'Traits and Cofactors', + 'Phenotypes'), + ('Genotypes', + 'DNA Markers and SNPs', + 'Genotypes'), + ['M', 'M', 'Molecular Trait Datasets']], + 'BXD': [('Phenotypes', + 'Traits and Cofactors', + 'Phenotypes'), + ('Genotypes', + 'DNA Markers and SNPs', + 'Genotypes'), + ['M', 'M', 'Molecular Trait Datasets']] + } + } + @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""" @@ -309,3 +345,41 @@ class TestGenMenu(unittest.TestCase): 'BXD': [['M', 'M', 'Molecular Trait Datasets']]}} self.assertEqual(get_types(self.test_group), expected_result) + + @mock.patch('wqflask.api.gen_menu.build_datasets') + def test_get_datasets_with_existent_datasets(self, + build_datasets_mock): + """Test correct dataset is returned with existent build_datasets""" + build_datasets_mock.return_value = "Test" + expected_result = { + 'mouse': { + 'H_T2': {'Genotypes': 'Test', + 'M': 'Test', + 'Phenotypes': 'Test'}, + 'H_T1': {'Genotypes': 'Test', + 'M': 'Test', + 'Phenotypes': 'Test'}}, + 'human': {'HLC': {'Genotypes': 'Test', + 'M': 'Test', + 'Phenotypes': 'Test'}, + 'BXD': {'Genotypes': 'Test', + 'M': 'Test', + 'Phenotypes': 'Test'}}} + self.maxDiff = None + self.assertEqual(get_datasets(self.test_type), + expected_result) + + @mock.patch('wqflask.api.gen_menu.build_datasets') + def test_get_datasets_with_non_existent_datasets(self, + build_datasets_mock): + """Test correct dataset is returned with non-existent build_datasets""" + build_datasets_mock.return_value = None + expected_result = { + 'mouse': { + 'H_T2': {}, + 'H_T1': {}}, + 'human': {'HLC': {}, + 'BXD': {}}} + self.assertEqual(get_datasets(self.test_type), + expected_result) + |