@@ -22,8 +22,8 @@ def setUp(self):
22
22
23
23
def test_unauthenticated_client (self ):
24
24
"""
25
- Test that an unauthenticated client receives a 401 Unauthorized response
26
- when attempting to access the clinic details endpoint.
25
+ Test that an unauthenticated client receives a 401 Unauthorized
26
+ response when attempting to access the clinic details endpoint.
27
27
"""
28
28
response = self .client .get (self .url , {"clinic_code" : self .clinic .value })
29
29
self .assertEqual (response .status_code , status .HTTP_401_UNAUTHORIZED )
@@ -64,3 +64,51 @@ def test_successful_clinic_retrieval(self):
64
64
self .assertEqual (response .status_code , status .HTTP_200_OK )
65
65
self .assertEqual (response .data ["code" ], self .clinic .value )
66
66
self .assertEqual (response .data ["name" ], self .clinic .name )
67
+
68
+ def test_clinic_code_with_space (self ):
69
+ """
70
+ Test that the endpoint returns a 200 successfully retrieves clinic
71
+ details when a valid clinic_code is contains a space.
72
+ """
73
+ response = self .api_client .get (self .url , {"clinic_code" : "123 456" })
74
+ self .assertEqual (response .status_code , status .HTTP_200_OK )
75
+ self .assertEqual (response .data ["code" ], self .clinic .value )
76
+ self .assertEqual (response .data ["name" ], self .clinic .name )
77
+
78
+ def test_clinic_code_with_clinic_name (self ):
79
+ """
80
+ Test that the endpoint returns a 200 successfully retrieves clinic
81
+ details when a valid clinic_code is contains a clinic name.
82
+ """
83
+ response = self .api_client .get (self .url , {"clinic_code" : "123456 Test Clinic" })
84
+ self .assertEqual (response .status_code , status .HTTP_200_OK )
85
+ self .assertEqual (response .data ["code" ], self .clinic .value )
86
+ self .assertEqual (response .data ["name" ], self .clinic .name )
87
+
88
+ def test_clinic_code_with_a_dash (self ):
89
+ """
90
+ Test that the endpoint returns a 200 successfully retrieves clinic
91
+ details when a valid clinic_code is contains a dash.
92
+ """
93
+ response = self .api_client .get (self .url , {"clinic_code" : "123-456" })
94
+ self .assertEqual (response .status_code , status .HTTP_200_OK )
95
+ self .assertEqual (response .data ["code" ], self .clinic .value )
96
+ self .assertEqual (response .data ["name" ], self .clinic .name )
97
+
98
+ def test_clinic_code_with_invalid_code (self ):
99
+ """
100
+ Test that the endpoint returns a 400 Bad Request response
101
+ when the clinic code parameter is invalid.
102
+ """
103
+ response = self .api_client .get (self .url , {"clinic_code" : "123 clinic" })
104
+ self .assertEqual (response .status_code , status .HTTP_400_BAD_REQUEST )
105
+ self .assertEqual (response .data , {"error" : "invalid" })
106
+
107
+ def test_clinic_code_not_found (self ):
108
+ """
109
+ Test that the endpoint returns a 404 Not Found response
110
+ when the clinic code provided does not exist.
111
+ """
112
+ response = self .api_client .get (self .url , {"clinic_code" : "246 810" })
113
+ self .assertEqual (response .status_code , status .HTTP_404_NOT_FOUND )
114
+ self .assertEqual (response .data , {"error" : "clinic not found" })
0 commit comments