From 79f931b0fbe0712954201a15278f9088fd7cdb8a Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Mon, 8 Mar 2021 10:52:44 +0300 Subject: Add "/gemma/k-gwa-compute/" --- tests/integration/test_gemma.py | 47 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'tests') diff --git a/tests/integration/test_gemma.py b/tests/integration/test_gemma.py index 4573de1..5b03cc4 100644 --- a/tests/integration/test_gemma.py +++ b/tests/integration/test_gemma.py @@ -405,3 +405,50 @@ 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_without_loco_covars(self, mock_redis, + mock_path_exist, mock_json, + mock_hash, mock_queue_cmd): + """Test /gemma/k-gwa-compute/ + + """ + 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/" "my-token")) + mock_hash.assert_called_with([ + '/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 -- " + "-g /tmp/my-token/genofile.txt " + "-p /tmp/my-token/phenofile.txt " + "-a /tmp/my-token/snpfile.txt " + "-gk > /tmp/my-token/hash-output.json " + "&& gemma-wrapper --json " + "--input /tmp/my-token/hash-output.json -- " + "-g /tmp/my-token/genofile.txt " + "-p /tmp/my-token/phenofile.txt " + "-a /tmp/my-token/snpfile.txt -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" + }) -- cgit v1.2.3