/
nhif_inpatient.py
72 lines (58 loc) · 2.5 KB
/
nhif_inpatient.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
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
"""
This test for nhif inpatient end point
"""
import unittest
from healthtools.manage import app
class TestSetup(unittest.TestCase):
def setUp(self):
self.client = app.test_client()
class TestNhifInpatientAPIWithDoctype(TestSetup):
"""
This tests nhif-inpatient search api with doctype
"""
def test_nhif_inpatient_endpoint_without_query(self):
"""
This tests running nhif-inpatient endpoint with valid doctype and no query
"""
response = self.client.get("search/nhif-inpatient?q=")
self.assertIn(b"MARIE STOPES KENYA LIMITED", response.data)
def test_nhif_inpatient_endpoint_gets_nhif_inpatient(self):
"""
This tests running nhif-inpatient endpoint with valid doctype and query
"""
response = self.client.get("search/nhif-inpatient?q=MATHARE")
self.assertIn(b"OK", response.data)
def test_nhif_inpatient_endpoint_with_bad_endpoint(self):
"""
This tests running an endpoint with incorrect/unavailable doctype
"""
response = self.client.get("search/nhifinpatient?q=MATHARE")
self.assertIn(b'"status": "FAILED"', response.data)
class TestNhifInpatientAPIWithoutDoctype(TestSetup):
"""
This tests nhif-inpatient search api without doctype, keywords are used instead
"""
def test_nhif_inpatient_endpoint_without_keyword_in_query(self):
response = self.client.get("search?q=Kilifi")
self.assertIn(b'"status": "FAILED"', response.data)
def test_nhif_inpatient_endpoint_gets_nhif_inpatient(self):
response = self.client.get("search?q=bima inpatient Kilifi")
self.assertIn(b"OK", response.data)
def test_nhif_inpatient_endpoint_with_keyword_only(self):
"""
This tests running nhif-inpatient endpoint with correct available keyword only
"""
response = self.client.get("search?q=inpatient insurance")
self.assertIn(b'"status": "FAILED"', response.data)
def test_nhif_inpatient_endpoint_without_query(self):
"""
This tests running nhif-inpatient endpoint without query
"""
response = self.client.get("search?q=")
self.assertIn(b'"status": "FAILED"', response.data)
def test_nhif_inpatient_endpoint_with_nonkeyword(self):
"""
This tests running nhif-inpatient endpoint with a keyword that is unavailable.
"""
response = self.client.get("search?q=maji Kilifi")
self.assertIn(b'"status": "FAILED"', response.data)