about summary refs log tree commit diff
path: root/tests/integration
diff options
context:
space:
mode:
authorBonfaceKilz2021-03-04 21:46:24 +0300
committerBonfaceKilz2021-03-08 21:09:58 +0300
commit47684b060649695f32a7fe465f018b8ffb53cf37 (patch)
tree8a117da944423d286e8160aea52f49e838d0bd6a /tests/integration
parentd072471bc353663149203d29a82fa9b7b2b95a1d (diff)
downloadgenenetwork3-47684b060649695f32a7fe465f018b8ffb53cf37.tar.gz
Add new endpoint: "/gwa-compute/<k_filename>/loco/maf/<maf>/<token>"
Diffstat (limited to 'tests/integration')
-rw-r--r--tests/integration/test_gemma.py52
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/integration/test_gemma.py b/tests/integration/test_gemma.py
index 0c2afdc..45c9148 100644
--- a/tests/integration/test_gemma.py
+++ b/tests/integration/test_gemma.py
@@ -290,3 +290,55 @@ class GemmaAPITest(unittest.TestCase):
             "status": "queued",
             "output_file": "hash-gwa-output.json"
         })
+
+    # pylint: disable=R0913
+    @mock.patch("gn3.api.gemma.queue_cmd")
+    @mock.patch("gn3.api.gemma.compose_gemma_cmd")
+    @mock.patch("gn3.api.gemma.get_hash_of_files")
+    @mock.patch("gn3.api.gemma.jsonfile_to_dict")
+    @mock.patch("gn3.api.gemma.do_paths_exist")
+    def test_gwa_compute_with_loco_only(self, mock_path_exist,
+                                        mock_json, mock_hash,
+                                        mock_cmd,
+                                        mock_queue_cmd):
+        """Test /gemma/gwa-compute/<k-inputfile>/loco/maf/<maf>/<token>
+
+        """
+        mock_path_exist.return_value = True
+        mock_queue_cmd.return_value = "my-unique-id"
+        mock_json.return_value = {
+            "geno": "genofile.txt",
+            "pheno": "phenofile.txt",
+            "snps": "snpfile.txt",
+            "covar": "covarfile.txt",
+        }
+        mock_hash.return_value = "hash"
+        mock_cmd.return_value = ("gemma-wrapper --json -- "
+                                 "-debug -g "
+                                 "genotype_name.txt "
+                                 "-p traitfilename.txt "
+                                 "-a genotype_snps.txt "
+                                 "-gk > k_output_filename.json")
+        response = self.app.post(("/api/gemma/gwa-compute/"
+                                  "hash-k-output.json/loco/"
+                                  "maf/21/my-token"))
+        mock_hash.assert_called_once_with(['/tmp/my-token/genofile.txt',
+                                           '/tmp/my-token/phenofile.txt',
+                                           '/tmp/my-token/snpfile.txt'])
+        mock_cmd.assert_called_once_with(
+            gemma_wrapper_cmd='gemma-wrapper',
+            gemma_wrapper_kwargs={
+                'loco': '--input /tmp/my-token/hash-k-output.json'
+            },
+            gemma_kwargs={'g': '/tmp/my-token/genofile.txt',
+                          'p': '/tmp/my-token/phenofile.txt',
+                          'a': '/tmp/my-token/snpfile.txt',
+                          'lmm': 9,
+                          'maf': 21},
+            gemma_args=["-gk", ">",
+                        '/tmp/my-token/hash-gwa-output.json'])
+        self.assertEqual(response.get_json(), {
+            "unique_id": "my-unique-id",
+            "status": "queued",
+            "output_file": "hash-gwa-output.json"
+        })