Skip to content

Commit afa939c

Browse files
committed
Add method not allowed test.
1 parent 39c0cd8 commit afa939c

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests.py

+26
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,21 @@ def get_response(self, url):
3535

3636
return response
3737

38+
def test_post_yields_method_not_allowed(self):
39+
"""
40+
Sending a POST request should yield a 405 Method Not Allowed response
41+
"""
42+
43+
conn = http.client.HTTPConnection('localhost:10000')
44+
conn.request('POST', '/')
45+
46+
response = conn.getresponse()
47+
48+
conn.close()
49+
50+
self.assertEqual(response.getcode(), 405)
51+
52+
3853
def test_get_sample_text_content(self):
3954
"""
4055
A call to /sample.txt returns the correct body
@@ -173,6 +188,17 @@ def test_root_index(self):
173188
for path in os.listdir(local_path):
174189
self.assertIn(path, body, error_comment)
175190

191+
def test_ok_response_at_root_index(self):
192+
"""
193+
A call to / at least yields a 200 OK response
194+
"""
195+
196+
directory = ''
197+
web_path = '/' + directory
198+
199+
response = self.get_response(web_path)
200+
201+
self.assertEqual(response.getcode(), 200)
176202

177203

178204
if __name__ == '__main__':

0 commit comments

Comments
 (0)