aboutsummaryrefslogtreecommitdiff
path: root/tests/integration
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2022-02-14 06:56:32 +0300
committerFrederick Muriuki Muriithi2022-02-17 06:37:30 +0300
commit74044f3c7985308b4996da3a52f91c5c20a19194 (patch)
treed86714b859b31cbbd1755522f8abd8eed16e321b /tests/integration
parent67f517aa0f44f55dc691ffd791bf22ef7af0b02c (diff)
downloadgenenetwork3-74044f3c7985308b4996da3a52f91c5c20a19194.tar.gz
Use pytest's "mark" feature to categorise tests
Use pytest's `mark` feature to explicitly categorise the tests and run them per category
Diffstat (limited to 'tests/integration')
-rw-r--r--tests/integration/test_correlation.py4
-rw-r--r--tests/integration/test_gemma.py14
-rw-r--r--tests/integration/test_general.py8
-rw-r--r--tests/integration/test_wgcna.py3
4 files changed, 28 insertions, 1 deletions
diff --git a/tests/integration/test_correlation.py b/tests/integration/test_correlation.py
index bdd9bce..cf63c17 100644
--- a/tests/integration/test_correlation.py
+++ b/tests/integration/test_correlation.py
@@ -1,6 +1,7 @@
"""module contains integration tests for correlation"""
from unittest import TestCase
from unittest import mock
+import pytest
from gn3.app import create_app
@@ -10,6 +11,7 @@ class CorrelationIntegrationTest(TestCase):
def setUp(self):
self.app = create_app().test_client()
+ @pytest.mark.integration_test
@mock.patch("gn3.api.correlation.compute_all_sample_correlation")
def test_sample_r_correlation(self, mock_compute_samples):
"""Test /api/correlation/sample_r/{method}"""
@@ -61,6 +63,7 @@ class CorrelationIntegrationTest(TestCase):
self.assertEqual(response.status_code, 200)
self.assertEqual(response.get_json(), api_response)
+ @pytest.mark.integration_test
@mock.patch("gn3.api.correlation.compute_all_lit_correlation")
@mock.patch("gn3.api.correlation.database_connector")
def test_lit_correlation(self, database_connector, mock_compute_corr):
@@ -80,6 +83,7 @@ class CorrelationIntegrationTest(TestCase):
self.assertEqual(mock_compute_corr.call_count, 1)
self.assertEqual(response.status_code, 200)
+ @pytest.mark.integration_test
@mock.patch("gn3.api.correlation.compute_tissue_correlation")
def test_tissue_correlation(self, mock_tissue_corr):
"""Test api/correlation/tissue_corr/{corr_method}"""
diff --git a/tests/integration/test_gemma.py b/tests/integration/test_gemma.py
index f871173..0515539 100644
--- a/tests/integration/test_gemma.py
+++ b/tests/integration/test_gemma.py
@@ -7,6 +7,8 @@ from dataclasses import dataclass
from typing import Callable
from unittest import mock
+import pytest
+
from gn3.app import create_app
@@ -30,6 +32,7 @@ class GemmaAPITest(unittest.TestCase):
"TMPDIR": "/tmp"
}).test_client()
+ @pytest.mark.integration_test
@mock.patch("gn3.api.gemma.run_cmd")
def test_get_version(self, mock_run_cmd):
"""Test that the correct response is returned"""
@@ -38,6 +41,7 @@ class GemmaAPITest(unittest.TestCase):
self.assertEqual(response.get_json(), {"status": 0, "output": "v1.9"})
self.assertEqual(response.status_code, 200)
+ @pytest.mark.integration_test
@mock.patch("gn3.api.gemma.redis.Redis")
def test_check_cmd_status(self, mock_redis):
"""Test that you can check the status of a given command"""
@@ -52,6 +56,7 @@ class GemmaAPITest(unittest.TestCase):
name="cmd::2021-02-1217-3224-3224-1234", key="status")
self.assertEqual(response.get_json(), {"status": "test"})
+ @pytest.mark.integration_test
@mock.patch("gn3.api.gemma.queue_cmd")
@mock.patch("gn3.computations.gemma.get_hash_of_files")
@mock.patch("gn3.api.gemma.jsonfile_to_dict")
@@ -94,6 +99,7 @@ class GemmaAPITest(unittest.TestCase):
"unique_id": "my-unique-id"
})
+ @pytest.mark.integration_test
@mock.patch("gn3.api.gemma.queue_cmd")
@mock.patch("gn3.computations.gemma.get_hash_of_files")
@mock.patch("gn3.api.gemma.jsonfile_to_dict")
@@ -137,6 +143,7 @@ class GemmaAPITest(unittest.TestCase):
"unique_id": "my-unique-id"
})
+ @pytest.mark.integration_test
@mock.patch("gn3.api.gemma.queue_cmd")
@mock.patch("gn3.computations.gemma.get_hash_of_files")
@mock.patch("gn3.api.gemma.jsonfile_to_dict")
@@ -187,6 +194,7 @@ class GemmaAPITest(unittest.TestCase):
"output_file": "hash-output.json"
})
+ @pytest.mark.integration_test
@mock.patch("gn3.api.gemma.queue_cmd")
@mock.patch("gn3.computations.gemma.get_hash_of_files")
@mock.patch("gn3.api.gemma.jsonfile_to_dict")
@@ -240,6 +248,7 @@ class GemmaAPITest(unittest.TestCase):
"output_file": "hash-output.json"
})
+ @pytest.mark.integration_test
@mock.patch("gn3.api.gemma.queue_cmd")
@mock.patch("gn3.computations.gemma.get_hash_of_files")
@mock.patch("gn3.api.gemma.jsonfile_to_dict")
@@ -292,6 +301,7 @@ class GemmaAPITest(unittest.TestCase):
"output_file": "hash-output.json"
})
+ @pytest.mark.integration_test
@mock.patch("gn3.api.gemma.queue_cmd")
@mock.patch("gn3.computations.gemma.get_hash_of_files")
@mock.patch("gn3.api.gemma.jsonfile_to_dict")
@@ -346,6 +356,7 @@ class GemmaAPITest(unittest.TestCase):
"output_file": "hash-output.json"
})
+ @pytest.mark.integration_test
@mock.patch("gn3.api.gemma.queue_cmd")
@mock.patch("gn3.computations.gemma.get_hash_of_files")
@mock.patch("gn3.api.gemma.jsonfile_to_dict")
@@ -401,6 +412,7 @@ class GemmaAPITest(unittest.TestCase):
"output_file": "hash-output.json"
})
+ @pytest.mark.integration_test
@mock.patch("gn3.api.gemma.queue_cmd")
@mock.patch("gn3.computations.gemma.get_hash_of_files")
@mock.patch("gn3.api.gemma.jsonfile_to_dict")
@@ -465,6 +477,7 @@ class GemmaAPITest(unittest.TestCase):
"output_file": "hash-output.json"
})
+ @pytest.mark.integration_test
@mock.patch("gn3.api.gemma.queue_cmd")
@mock.patch("gn3.computations.gemma.get_hash_of_files")
@mock.patch("gn3.api.gemma.jsonfile_to_dict")
@@ -530,6 +543,7 @@ class GemmaAPITest(unittest.TestCase):
"output_file": "hash-output.json"
})
+ @pytest.mark.integration_test
@mock.patch("gn3.api.gemma.queue_cmd")
@mock.patch("gn3.computations.gemma.get_hash_of_files")
@mock.patch("gn3.api.gemma.jsonfile_to_dict")
diff --git a/tests/integration/test_general.py b/tests/integration/test_general.py
index 8fc2b43..9d87449 100644
--- a/tests/integration/test_general.py
+++ b/tests/integration/test_general.py
@@ -1,8 +1,10 @@
"""Integration tests for some 'general' API endpoints"""
import os
import unittest
-
from unittest import mock
+
+import pytest
+
from gn3.app import create_app
@@ -11,6 +13,7 @@ class GeneralAPITest(unittest.TestCase):
def setUp(self):
self.app = create_app().test_client()
+ @pytest.mark.integration_test
def test_metadata_endpoint_exists(self):
"""Test that /metadata/upload exists"""
response = self.app.post("/api/metadata/upload/d41d86-e4ceEo")
@@ -19,6 +22,7 @@ class GeneralAPITest(unittest.TestCase):
{"status": 128,
"error": "Please provide a file!"})
+ @pytest.mark.integration_test
@mock.patch("gn3.api.general.extract_uploaded_file")
def test_metadata_file_upload(self, mock_extract_upload):
"""Test correct upload of file"""
@@ -37,6 +41,7 @@ class GeneralAPITest(unittest.TestCase):
{"status": 0,
"token": "d41d86-e4ceEo"})
+ @pytest.mark.integration_test
def test_metadata_file_wrong_upload(self):
"""Test that incorrect upload return correct status code"""
response = self.app.post("/api/metadata/upload/d41d86-e4ceEo",
@@ -47,6 +52,7 @@ class GeneralAPITest(unittest.TestCase):
{"status": 128,
"error": "gzip failed to unpack file"})
+ @pytest.mark.integration_test
@mock.patch("gn3.api.general.run_cmd")
def test_run_r_qtl(self, mock_run_cmd):
"""Test correct upload of file"""
diff --git a/tests/integration/test_wgcna.py b/tests/integration/test_wgcna.py
index 078449d..5880b40 100644
--- a/tests/integration/test_wgcna.py
+++ b/tests/integration/test_wgcna.py
@@ -3,6 +3,8 @@
from unittest import TestCase
from unittest import mock
+import pytest
+
from gn3.app import create_app
@@ -12,6 +14,7 @@ class WgcnaIntegrationTest(TestCase):
def setUp(self):
self.app = create_app().test_client()
+ @pytest.mark.integration_test
@mock.patch("gn3.api.wgcna.call_wgcna_script")
def test_wgcna_endpoint(self, mock_wgcna_script):
"""test /api/wgcna/run_wgcna endpoint"""