aboutsummaryrefslogtreecommitdiff
path: root/tests/integration
diff options
context:
space:
mode:
authorzsloan2021-10-12 18:56:34 +0000
committerzsloan2021-10-12 18:56:34 +0000
commit0f396f4a1a753d449cf2975fc425d587d9350689 (patch)
treec9dac243dc05e5cb90ccb7f1d96fd599986bf60a /tests/integration
parent976660ce9ef915426c7ce5ff9077b439e4102a2c (diff)
parent77c274b79c3ec01de60e90db3299763cb58f715b (diff)
downloadgenenetwork3-0f396f4a1a753d449cf2975fc425d587d9350689.tar.gz
Merge branch 'main' of https://github.com/genenetwork/genenetwork3 into feature/add_rqtl_pairscan
Diffstat (limited to 'tests/integration')
-rw-r--r--tests/integration/test_wgcna.py73
1 files changed, 73 insertions, 0 deletions
diff --git a/tests/integration/test_wgcna.py b/tests/integration/test_wgcna.py
new file mode 100644
index 0000000..078449d
--- /dev/null
+++ b/tests/integration/test_wgcna.py
@@ -0,0 +1,73 @@
+"""integration tests for wgcna"""
+
+from unittest import TestCase
+from unittest import mock
+
+from gn3.app import create_app
+
+
+class WgcnaIntegrationTest(TestCase):
+ """class contains wgcna integration tests"""
+
+ def setUp(self):
+ self.app = create_app().test_client()
+
+ @mock.patch("gn3.api.wgcna.call_wgcna_script")
+ def test_wgcna_endpoint(self, mock_wgcna_script):
+ """test /api/wgcna/run_wgcna endpoint"""
+
+ wgcna_output_data = {
+ "code": 0,
+ "output": "run script successfully",
+ "data": {
+ "ModEigens": {
+ "MEturquoise": [
+ 0.0646677768085351,
+ 0.137200224277058,
+ 0.63451113720732,
+ -0.544002665501479,
+ -0.489487590361863,
+ 0.197111117570427
+ ]
+ },
+ "net_colors": {
+ "X1": "turquoise",
+ "X2": "turquoise",
+ "X3": "turquoise",
+ "X4": "turquoise"
+ },
+ "imageLoc": "/WGCNAoutput_1uujpTIpC.png"
+ }
+ }
+
+ request_data = {
+ "trait_names": [
+ "1455537_at",
+ "1425637_at"
+ ],
+ "trait_sample_data": [
+ {
+ "129S1/SvImJ": 6.142,
+ "A/J": 5.31,
+ "AKR/J": 3.49,
+ "B6D2F1": 2.899,
+ "BALB/cByJ": 1.172,
+ "BALB/cJ": 7.396
+ },
+ {
+ "129S1/SvImJ": 1.42,
+ "A/J": 2.31,
+ "AKR/J": 5.49,
+ "B6D2F1": 3.899,
+ "BALB/cByJ": 1.172,
+ "BALB/cJ": 7.396
+ }
+ ]
+ }
+ mock_wgcna_script.return_value = wgcna_output_data
+
+ response = self.app.post("/api/wgcna/run_wgcna",
+ json=request_data, follow_redirects=True)
+
+ self.assertEqual(response.status_code, 200)
+ self.assertEqual(response.get_json(), wgcna_output_data)