From 529e72eb1aed89e018428cabdf63e98983c508ed Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Fri, 5 Mar 2021 16:00:25 +0300 Subject: Replace "compute_k_values" with "generate_gemma_cmd" --- tests/integration/test_gemma.py | 150 ++++++++++++++++++++-------------------- 1 file changed, 75 insertions(+), 75 deletions(-) (limited to 'tests/integration/test_gemma.py') diff --git a/tests/integration/test_gemma.py b/tests/integration/test_gemma.py index f4ac685..4573de1 100644 --- a/tests/integration/test_gemma.py +++ b/tests/integration/test_gemma.py @@ -187,21 +187,21 @@ class GemmaAPITest(unittest.TestCase): "-g /tmp/test-data/genofile.txt " "-p /tmp/test-data/phenofile.txt " "-a /tmp/test-data/snpfile.txt " - "-gk > /tmp/test-data/hash-k-output.json")) - self.assertEqual(response.get_json(), { - "output_file": "hash-k-output.json", - "status": "queued", - "unique_id": "my-unique-id" - }) + "-gk > /tmp/test-data/hash-output.json")) + self.assertEqual( + response.get_json(), { + "output_file": "hash-output.json", + "status": "queued", + "unique_id": "my-unique-id" + }) @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_compute_loco(self, mock_redis, mock_path_exist, - mock_json, mock_hash, - mock_queue_cmd): + def test_k_compute_loco(self, mock_redis, mock_path_exist, mock_json, + mock_hash, mock_queue_cmd): """Test /gemma/k-compute/loco//""" mock_path_exist.return_value, _redis_conn = True, mock.MagicMock() mock_redis.return_value = _redis_conn @@ -223,21 +223,21 @@ class GemmaAPITest(unittest.TestCase): "-g /tmp/test-data/genofile.txt " "-p /tmp/test-data/phenofile.txt " "-a /tmp/test-data/snpfile.txt " - "-gk > /tmp/test-data/hash-3R77Mz-k-output.json")) - self.assertEqual(response.get_json(), { - "output_file": "hash-3R77Mz-k-output.json", - "status": "queued", - "unique_id": "my-unique-id" - }) + "-gk > /tmp/test-data/hash-3R77Mz-output.json")) + self.assertEqual( + response.get_json(), { + "output_file": "hash-3R77Mz-output.json", + "status": "queued", + "unique_id": "my-unique-id" + }) @mock.patch("gn3.api.gemma.queue_cmd") - @mock.patch("gn3.api.gemma.get_hash_of_files") + @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_gwa_compute(self, mock_redis, mock_path_exist, - mock_json, mock_hash, - mock_queue_cmd): + def test_gwa_compute(self, mock_redis, mock_path_exist, mock_json, + mock_hash, mock_queue_cmd): """Test /gemma/gwa-compute//""" mock_path_exist.return_value, _redis_conn = True, mock.MagicMock() mock_redis.return_value = _redis_conn @@ -250,9 +250,10 @@ class GemmaAPITest(unittest.TestCase): mock_hash.return_value = "hash" response = self.app.post(("/api/gemma/gwa-compute/hash-k-output.json/" "my-token")) - mock_hash.assert_called_once_with(['/tmp/my-token/genofile.txt', - '/tmp/my-token/phenofile.txt', - '/tmp/my-token/snpfile.txt']) + mock_hash.assert_called_once_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, @@ -262,22 +263,21 @@ class GemmaAPITest(unittest.TestCase): " -- -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-gwa-output.json")) - self.assertEqual(response.get_json(), { - "unique_id": "my-unique-id", - "status": "queued", - "output_file": "hash-gwa-output.json" - }) + "-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" + }) @mock.patch("gn3.api.gemma.queue_cmd") - @mock.patch("gn3.api.gemma.get_hash_of_files") + @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_gwa_compute_with_covars(self, mock_redis, - mock_path_exist, - mock_json, mock_hash, - mock_queue_cmd): + def test_gwa_compute_with_covars(self, mock_redis, mock_path_exist, + mock_json, mock_hash, mock_queue_cmd): """Test /gemma/gwa-compute/covars//""" mock_path_exist.return_value, _redis_conn = True, mock.MagicMock() mock_redis.return_value = _redis_conn @@ -293,10 +293,10 @@ class GemmaAPITest(unittest.TestCase): response = self.app.post(("/api/gemma/gwa-compute/" "covars/hash-k-output.json/" "my-token")) - mock_hash.assert_called_once_with(['/tmp/my-token/genofile.txt', - '/tmp/my-token/phenofile.txt', - '/tmp/my-token/snpfile.txt', - '/tmp/my-token/covarfile.txt']) + mock_hash.assert_called_once_with([ + '/tmp/my-token/genofile.txt', '/tmp/my-token/phenofile.txt', + '/tmp/my-token/snpfile.txt', '/tmp/my-token/covarfile.txt' + ]) mock_queue_cmd.assert_called_once_with( conn=_redis_conn, email=None, @@ -307,22 +307,21 @@ class GemmaAPITest(unittest.TestCase): "-p /tmp/my-token/phenofile.txt " "-a /tmp/my-token/snpfile.txt " "-c /tmp/my-token/covarfile.txt -lmm 9 " - "-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" - }) + "-gk > /tmp/my-token/hash-output.json")) + self.assertEqual( + response.get_json(), { + "unique_id": "my-unique-id", + "status": "queued", + "output_file": "hash-output.json" + }) @mock.patch("gn3.api.gemma.queue_cmd") - @mock.patch("gn3.api.gemma.get_hash_of_files") + @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_gwa_compute_with_loco_only(self, mock_redis, - mock_path_exist, - mock_json, mock_hash, - mock_queue_cmd): + def test_gwa_compute_with_loco_only(self, mock_redis, mock_path_exist, + mock_json, mock_hash, mock_queue_cmd): """Test /gemma/gwa-compute//loco/maf// """ @@ -336,35 +335,36 @@ class GemmaAPITest(unittest.TestCase): } mock_hash.return_value = "hash" response = self.app.post(("/api/gemma/gwa-compute/" - "hash-k-output.json/loco/" + "hash-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_hash.assert_called_once_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 --loco --input " - "/tmp/my-token/hash-k-output.json -- " + "/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 -maf 21.0 " - "-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" - }) + "-gk > /tmp/my-token/hash-output.json")) + self.assertEqual( + response.get_json(), { + "unique_id": "my-unique-id", + "status": "queued", + "output_file": "hash-output.json" + }) @mock.patch("gn3.api.gemma.queue_cmd") - @mock.patch("gn3.api.gemma.get_hash_of_files") + @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_gwa_compute_with_loco_covars(self, mock_redis, - mock_path_exist, + def test_gwa_compute_with_loco_covars(self, mock_redis, mock_path_exist, mock_json, mock_hash, mock_queue_cmd): """Test /gemma/gwa-compute//loco/covariates/maf/ @@ -381,27 +381,27 @@ class GemmaAPITest(unittest.TestCase): } mock_hash.return_value = "hash" response = self.app.post(("/api/gemma/gwa-compute/" - "hash-k-output.json/loco/" + "hash-output.json/loco/" "covariates/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', - "/tmp/my-token/covarfile.txt" - ]) + mock_hash.assert_called_once_with([ + '/tmp/my-token/genofile.txt', '/tmp/my-token/phenofile.txt', + '/tmp/my-token/snpfile.txt', "/tmp/my-token/covarfile.txt" + ]) mock_queue_cmd.assert_called_once_with( conn=_redis_conn, email=None, job_queue='GN3::job-queue', cmd=("gemma-wrapper --json --loco --input " - "/tmp/my-token/hash-k-output.json -- " + "/tmp/my-token/hash-output.json -- " "-g /tmp/my-token/genofile.txt " "-p /tmp/my-token/phenofile.txt " "-a /tmp/my-token/snpfile.txt " "-c /tmp/my-token/covarfile.txt " "-lmm 9 -maf 21.0 " - "-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" - }) + "-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