about summary refs log tree commit diff
diff options
context:
space:
mode:
authorzsloan2021-02-23 21:43:27 +0000
committerzsloan2021-02-23 21:43:27 +0000
commitf132a7376e5ece48c03166cd9f85271d8514eecd (patch)
tree946dcbfad2bc476b4e6366b800e311eed9421c35
parentb6f6c9b473802997be152e6962879175827c014d (diff)
parent4817d78b22b899b9beb3fd3a99a10d6cbcee22d6 (diff)
downloadgenenetwork2-f132a7376e5ece48c03166cd9f85271d8514eecd.tar.gz
Merge branch 'testing' of github.com:genenetwork/genenetwork2 into testing
-rw-r--r--wqflask/tests/unit/utility/test_authentication_tools.py8
-rw-r--r--wqflask/tests/unit/wqflask/api/test_gen_menu.py7
-rw-r--r--wqflask/tests/unit/wqflask/marker_regression/test_run_mapping.py7
-rw-r--r--wqflask/wqflask/api/gen_menu.py2
4 files changed, 15 insertions, 9 deletions
diff --git a/wqflask/tests/unit/utility/test_authentication_tools.py b/wqflask/tests/unit/utility/test_authentication_tools.py
index 5c391be5..fff5fd8f 100644
--- a/wqflask/tests/unit/utility/test_authentication_tools.py
+++ b/wqflask/tests/unit/utility/test_authentication_tools.py
@@ -5,7 +5,6 @@ from unittest import mock
 from utility.authentication_tools import check_resource_availability
 from utility.authentication_tools import add_new_resource
 
-
 class TestResponse:
     """Mock Test Response after a request"""
     @property
@@ -38,7 +37,7 @@ class TestCheckResourceAvailability(unittest.TestCase):
     """Test methods related to checking the resource availability"""
     @mock.patch('utility.authentication_tools.add_new_resource')
     @mock.patch('utility.authentication_tools.Redis')
-    @mock.patch('utility.authentication_tools.g', mock.Mock())
+    @mock.patch('utility.authentication_tools.g', TestUserSession())
     @mock.patch('utility.authentication_tools.get_resource_id')
     def test_check_resource_availability_default_mask(
             self,
@@ -46,6 +45,7 @@ class TestCheckResourceAvailability(unittest.TestCase):
             redis_mock,
             add_new_resource_mock):
         """Test the resource availability with default mask"""
+
         resource_id_mock.return_value = 1
         redis_mock.smembers.return_value = []
         test_dataset = mock.MagicMock()
@@ -64,7 +64,7 @@ class TestCheckResourceAvailability(unittest.TestCase):
             redis_mock,
             add_new_resource_mock,
             requests_mock):
-        """Test the resource availability with default mask"""
+        """Test the resource availability with non-default mask"""
         resource_id_mock.return_value = 1
         redis_mock.smembers.return_value = []
         add_new_resource_mock.return_value = {"default_mask": 2}
@@ -89,7 +89,7 @@ class TestCheckResourceAvailability(unittest.TestCase):
             requests_mock):
         """Test the resource availability if the user is the super user"""
         resource_id_mock.return_value = 1
-        redis_mock.smembers.return_value = ["Jane"]
+        redis_mock.smembers.return_value = [b"Jane"]
         add_new_resource_mock.return_value = {"default_mask": 2}
         requests_mock.return_value = TestResponse()
         test_dataset = mock.MagicMock()
diff --git a/wqflask/tests/unit/wqflask/api/test_gen_menu.py b/wqflask/tests/unit/wqflask/api/test_gen_menu.py
index cc666f0c..57eb1650 100644
--- a/wqflask/tests/unit/wqflask/api/test_gen_menu.py
+++ b/wqflask/tests/unit/wqflask/api/test_gen_menu.py
@@ -244,10 +244,11 @@ class TestGenMenu(unittest.TestCase):
             "ProbeFreeze, InbredSet, Tissue, Species WHERE " +
             "Species.Name = 'Mouse' AND Species.Id = " +
             "InbredSet.SpeciesId AND InbredSet.Name = 'HLC' AND " +
-            "ProbeSetFreeze.ProbeFreezeId = ProbeFreeze.Id and " +
+            "ProbeSetFreeze.ProbeFreezeId = ProbeFreeze.Id AND " +
             "Tissue.Name = 'mRNA' AND ProbeFreeze.TissueId = " +
-            "Tissue.Id and ProbeFreeze.InbredSetId = InbredSet.Id " +
-            "ORDER BY ProbeSetFreeze.OrderList DESC")
+            "Tissue.Id AND ProbeFreeze.InbredSetId = InbredSet.Id AND " +
+            "ProbeSetFreeze.public > 0 " +
+            "ORDER BY -ProbeSetFreeze.OrderList DESC, ProbeSetFreeze.CreateTime DESC")
 
     @mock.patch('wqflask.api.gen_menu.build_datasets')
     @mock.patch('wqflask.api.gen_menu.g')
diff --git a/wqflask/tests/unit/wqflask/marker_regression/test_run_mapping.py b/wqflask/tests/unit/wqflask/marker_regression/test_run_mapping.py
index 4129cc0c..a29d8cfb 100644
--- a/wqflask/tests/unit/wqflask/marker_regression/test_run_mapping.py
+++ b/wqflask/tests/unit/wqflask/marker_regression/test_run_mapping.py
@@ -180,14 +180,19 @@ class TestRunMapping(unittest.TestCase):
 
             with mock.patch("wqflask.marker_regression.run_mapping.datetime.datetime", new=datetime_mock):
                 export_mapping_results(dataset=self.dataset, trait=self.trait, markers=markers,
-                                       results_path="~/results", mapping_scale="physic", score_type="-log(p)")
+                                       results_path="~/results", mapping_scale="physic", score_type="-log(p)",
+                                       transform="qnorm", covariates="Dataset1:Trait1,Dataset2:Trait2", n_samples="100")
 
                 write_calls = [
                     mock.call('Time/Date: 09/01/19 / 10:12:12\n'),
                     mock.call('Population: Human GP1_\n'), mock.call(
                         'Data Set: dataser_1\n'),
+                    mock.call('N Samples: 100\n'), mock.call('Transform - Quantile Normalized\n'),
                     mock.call('Gene Symbol: IGFI\n'), mock.call(
                         'Location: X1 @ 123313 Mb\n'),
+                    mock.call('Cofactors (dataset - trait):\n'),
+                    mock.call('Trait1 - Dataset1\n'),
+                    mock.call('Trait2 - Dataset2\n'),
                     mock.call('\n'), mock.call('Name,Chr,'),
                     mock.call('Mb,-log(p)'), mock.call('Cm,-log(p)'),
                     mock.call(',Additive'), mock.call(',Dominance'),
diff --git a/wqflask/wqflask/api/gen_menu.py b/wqflask/wqflask/api/gen_menu.py
index 4ce19fdb..18afc5ad 100644
--- a/wqflask/wqflask/api/gen_menu.py
+++ b/wqflask/wqflask/api/gen_menu.py
@@ -207,7 +207,7 @@ def build_datasets(species, group, type_name):
              "InbredSet.SpeciesId AND InbredSet.Name = '{1}' "
              "AND ProbeSetFreeze.ProbeFreezeId = ProbeFreeze.Id "
              "AND Tissue.Name = '{2}' AND ProbeFreeze.TissueId = "
-             "Tissue.Id and ProbeFreeze.InbredSetId = InbredSet.Id "
+             "Tissue.Id AND ProbeFreeze.InbredSetId = InbredSet.Id "
              "AND ProbeSetFreeze.public > 0 "
              "ORDER BY -ProbeSetFreeze.OrderList DESC, ProbeSetFreeze.CreateTime DESC").format(species, group, type_name)).fetchall()