aboutsummaryrefslogtreecommitdiff
path: root/tests/integration
diff options
context:
space:
mode:
authorBonfaceKilz2021-03-08 15:06:02 +0300
committerBonfaceKilz2021-03-08 21:09:58 +0300
commitcb1adaceb074f2d2d7a0d903808a1853092e127f (patch)
treef8c6ec5559cccee5adce969f7d6ace1b956d1fab /tests/integration
parent504cd5748e5fa71a539b095958fe71a20f5ca443 (diff)
downloadgenenetwork3-cb1adaceb074f2d2d7a0d903808a1853092e127f.tar.gz
Add "/gemma/k-gwa-compute/loco/<chromosomes>/maf/<maf>/<token>"
Diffstat (limited to 'tests/integration')
-rw-r--r--tests/integration/test_gemma.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/integration/test_gemma.py b/tests/integration/test_gemma.py
index 2055829..fdc061d 100644
--- a/tests/integration/test_gemma.py
+++ b/tests/integration/test_gemma.py
@@ -507,3 +507,57 @@ class GemmaAPITest(unittest.TestCase):
"status": "queued",
"output_file": "hash-output.json"
})
+
+ @mock.patch("gn3.api.gemma.queue_cmd")
+ @mock.patch("gn3.computations.gemma.get_hash_of_files")
+ @mock.patch("gn3.api.gemma.jsonfile_to_dict")
+ @mock.patch("gn3.api.gemma.do_paths_exist")
+ @mock.patch("gn3.api.gemma.redis.Redis")
+ def test_k_gwa_compute_with_loco_only(self, mock_redis, mock_path_exist,
+ mock_json, mock_hash,
+ mock_queue_cmd):
+ """Test /gemma/k-gwa-compute/loco/<chromosomes>/maf/<maf>/<token>
+
+ """
+ mock_path_exist.return_value, _redis_conn = True, mock.MagicMock()
+ mock_redis.return_value = _redis_conn
+ mock_queue_cmd.return_value = "my-unique-id"
+ mock_json.return_value = {
+ "geno": "genofile.txt",
+ "pheno": "phenofile.txt",
+ "snps": "snpfile.txt",
+ }
+ mock_hash.return_value = "hash"
+ response = self.app.post(
+ "/api/gemma/k-gwa-compute/loco/1%2C2%2C3%2C4/maf/9/my-token")
+ mock_hash.assert_has_calls([
+ mock.call([
+ '/tmp/my-token/genofile.txt', '/tmp/my-token/phenofile.txt',
+ '/tmp/my-token/snpfile.txt'
+ ]),
+ mock.call([
+ '/tmp/my-token/genofile.txt', '/tmp/my-token/phenofile.txt',
+ '/tmp/my-token/snpfile.txt'
+ ]),
+ ])
+ mock_queue_cmd.assert_called_once_with(
+ conn=_redis_conn,
+ email=None,
+ job_queue='GN3::job-queue',
+ cmd=("gemma-wrapper --json --loco --input 1,2,3,4 -- "
+ "-g /tmp/my-token/genofile.txt "
+ "-p /tmp/my-token/phenofile.txt "
+ "-a /tmp/my-token/snpfile.txt "
+ "-gk > /tmp/my-token/hash-+O9bus-output.json "
+ "&& gemma-wrapper --json --loco "
+ "--input /tmp/my-token/hash-+O9bus-output.json -- "
+ "-g /tmp/my-token/genofile.txt "
+ "-p /tmp/my-token/phenofile.txt "
+ "-a /tmp/my-token/snpfile.txt -maf 9.0 -lmm 9 "
+ "-gk > /tmp/my-token/hash-output.json"))
+ self.assertEqual(
+ response.get_json(), {
+ "unique_id": "my-unique-id",
+ "status": "queued",
+ "output_file": "hash-output.json"
+ })