-
Notifications
You must be signed in to change notification settings - Fork 5
/
unit_test.py
43 lines (33 loc) · 1.27 KB
/
unit_test.py
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
import os
import pqr
import unittest
import tempfile
class PQRTestCase(unittest.TestCase):
mol = "GNBHRKFJIUUOQI-UHFFFAOYSA-N"
def setUp(self):
pqr.pqr.config['TESTING'] = True
self.app = pqr.pqr.test_client()
def tearDown(self):
print "Done"
def test_json_api(self):
rv = self.app.get('/api/json/' + self.mol + '/')
assert rv.headers['content-type'] == 'application/json'
print '### JSON API endpoint is OK'
def test_search_name(self):
rv = self.app.get('/browse/?query=glucose&type=name')
assert rv.status_code == 200
print "### Name search is OK"
def test_search_inchi(self):
rv = self.app.get('/browse?query=GNBHRKFJIUUOQI-UHFFFAOYSA-N&type=inchi')
assert rv.status_code == 302
print "### InChIKey search is OK and redirecting properly"
def test_browse_api(self):
rv = self.app.get('/api/browse/water/name/')
assert rv.headers['content-type'] == 'application/json'
print '### Browse API endpoint is OK'
def test_status_api(self):
rv = self.app.get('/api/status/')
assert rv.headers['content-type'] == 'application/json'
print '### Status API endpoint is OK'
if __name__ == '__main__':
unittest.main()