forked from BioAnalyticResource/BAR_API
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_thalemine.py
More file actions
121 lines (95 loc) · 4.58 KB
/
test_thalemine.py
File metadata and controls
121 lines (95 loc) · 4.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
from api import app
from json import load
import unittest
@unittest.skip("Blocked")
class TestIntegrations(unittest.TestCase):
def setUp(self):
self.app_client = app.test_client()
def test_get_thalemine_gene_rifs(self):
"""This tests the data returned by the ThaleMine Gene RIFs
:return:
"""
# Valid data
response = self.app_client.get("/thalemine/gene_rifs/At1g01020")
# Delete query time data. It will always be different
response = response.json
response.pop("executionTime")
# Note: pytest is running from project root. So path is relative to project root
# Also, delete execution time from output before saving.
with open("tests/data/get_thalemine_gene_rifs_1.json") as json_file:
expected = load(json_file)
self.assertEqual(response, expected)
# Anther valid gene
response = self.app_client.get("/thalemine/gene_rifs/At1g01050")
# Delete query time data. It will always be different
response = response.json
response.pop("executionTime")
# Note: pytest is running from project root. So path is relative to project root
# Also, delete execution time from output before saving.
with open("tests/data/get_thalemine_gene_rifs_3.json") as json_file:
expected = load(json_file)
self.assertEqual(response, expected)
# Valid but does not exists
response = self.app_client.get("/thalemine/gene_rifs/At1g01010")
# Again, delete time data.
response = response.json
response.pop("executionTime")
with open("tests/data/get_thalemine_gene_rifs_2.json") as json_file:
expected = load(json_file)
self.assertEqual(response, expected)
# Invalid gene id
response = self.app_client.get("/thalemine/gene_rifs/At1g0101x")
expected = {"wasSuccessful": False, "error": "Invalid gene id"}
self.assertEqual(response.json, expected)
def test_get_thalemine_publications(self):
"""This tests the data returned by the ThaleMine publications endpoint
:return:
"""
# Valid data
response = self.app_client.get("/thalemine/publications/At1g01020")
# Delete query time data. It will always be different
response = response.json
response.pop("executionTime")
# Note: pytest is running from project root. So path is relative to project root
# Also, delete execution time from output before saving.
with open("tests/data/get_thalemine_publications_1.json") as json_file:
expected = load(json_file)
self.assertEqual(response, expected)
# Valid but does not exists
response = self.app_client.get("/thalemine/publications/At1g01011")
# Again, delete time data.
response = response.json
response.pop("executionTime")
with open("tests/data/get_thalemine_publications_2.json") as json_file:
expected = load(json_file)
self.assertEqual(response, expected)
# Invalid gene id
response = self.app_client.get("/thalemine/publications/At1g0101x")
expected = {"wasSuccessful": False, "error": "Invalid gene id"}
self.assertEqual(response.json, expected)
def test_get_thalemine_gene_information(self):
"""This tests the data returned by the ThaleMine gene information endpoint
:return:
"""
# Valid data
response = self.app_client.get("/thalemine/gene_information/At1g01010")
# Delete query time data. It will always be different
response = response.json
response.pop("executionTime")
# Note: pytest is running from project root. So path is relative to project root
# Also, delete execution time from output before saving.
with open("tests/data/get_thalemine_gene_information_1.json") as json_file:
expected = load(json_file)
self.assertEqual(response, expected)
# Valid but does not exists
response = self.app_client.get("/thalemine/gene_information/At1g01011")
# Again, delete time data.
response = response.json
response.pop("executionTime")
with open("tests/data/get_thalemine_gene_information_2.json") as json_file:
expected = load(json_file)
self.assertEqual(response, expected)
# Invalid gene id
response = self.app_client.get("/thalemine/gene_information/At1g0101x")
expected = {"wasSuccessful": False, "error": "Invalid gene id"}
self.assertEqual(response.json, expected)