aboutsummaryrefslogtreecommitdiff
path: root/wqflask/tests
diff options
context:
space:
mode:
authorBonfaceKilz2020-08-03 11:24:40 +0300
committerBonfaceKilz2020-08-03 16:44:48 +0300
commit61634e932f8e03f5f53a94a56ff23f50dba891d2 (patch)
tree8b56001db2ac4b86e3567a403f626832a20b3f22 /wqflask/tests
parent7f4b4b19c049a20c3040af22e104ac1d5fbff160 (diff)
downloadgenenetwork2-61634e932f8e03f5f53a94a56ff23f50dba891d2.tar.gz
Add test for "build_types"
* wqflask/tests/api/test_gen_menu.py: New test
Diffstat (limited to 'wqflask/tests')
-rw-r--r--wqflask/tests/api/test_gen_menu.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/wqflask/tests/api/test_gen_menu.py b/wqflask/tests/api/test_gen_menu.py
index ec380b6f..24899765 100644
--- a/wqflask/tests/api/test_gen_menu.py
+++ b/wqflask/tests/api/test_gen_menu.py
@@ -7,6 +7,7 @@ from wqflask.api.gen_menu import get_groups
from wqflask.api.gen_menu import phenotypes_exist
from wqflask.api.gen_menu import genotypes_exist
from wqflask.api.gen_menu import build_datasets
+from wqflask.api.gen_menu import build_types
class TestGenMenu(unittest.TestCase):
@@ -177,3 +178,29 @@ class TestGenMenu(unittest.TestCase):
"Tissue.Name = 'mRNA' AND ProbeFreeze.TissueId = " +
"Tissue.Id and ProbeFreeze.InbredSetId = InbredSet.Id " +
"ORDER BY ProbeSetFreeze.CreateTime DESC")
+
+ @mock.patch('wqflask.api.gen_menu.build_datasets')
+ @mock.patch('wqflask.api.gen_menu.g')
+ def test_build_types(self, db_mock, datasets_mock):
+ """Test that correct tissue metadata is returned"""
+ datasets_mock.return_value = [
+ ["112", 'HC_M2_0606_P', "Hippocampus Consortium M430v2 (Jun06) PDNN"]
+ ]
+ db_mock.db.execute.return_value.fetchall.return_value = (
+ ('Mouse Tissue'), ('Human Tissue'), ('Rat Tissue')
+ )
+ self.assertEqual(build_types('mouse', 'random group'),
+ [['M', 'M', 'Molecular Trait Datasets'],
+ ['H', 'H', 'Molecular Trait Datasets'],
+ ['R', 'R', 'Molecular Trait Datasets']])
+ db_mock.db.execute.assert_called_once_with(
+ "SELECT DISTINCT Tissue.Name " +
+ "FROM ProbeFreeze, ProbeSetFreeze, InbredSet, " +
+ "Tissue, Species WHERE Species.Name = 'mouse' " +
+ "AND Species.Id = InbredSet.SpeciesId AND " +
+ "InbredSet.Name = 'random group' AND " +
+ "ProbeFreeze.TissueId = Tissue.Id AND " +
+ "ProbeFreeze.InbredSetId = InbredSet.Id AND " +
+ "ProbeSetFreeze.ProbeFreezeId = ProbeFreeze.Id " +
+ "ORDER BY Tissue.Name"
+ )