test: Improved code coverage

This commit is contained in:
Kurt Griffiths
2013-01-21 17:51:39 -05:00
parent 983ef36b64
commit c854cc7486
3 changed files with 20 additions and 2 deletions

View File

@@ -1,3 +1,3 @@
#!/usr/bin/env bash
nosetests --with-coverage --cover-package=falcon
nosetests --with-coverage --cover-package=falcon --cover-min-percentage=90

View File

@@ -48,6 +48,12 @@ class TestHeaders(helpers.TestSuite):
content_length_header = ('Content-Length', content_length)
self.assertThat(headers, Contains(content_length_header))
def test_default_value(self):
self._simulate_request(self.test_route)
value = self.resource.req.get_header('X-Not-Found', '876')
self.assertEquals(value, '876')
def test_prefer_host_header(self):
self._simulate_request(self.test_route)

View File

@@ -38,7 +38,6 @@ class UnauthorizedResource:
'Missing or invalid token header.',
'Token')
class NotFoundResource:
def on_get(self, req, resp):
@@ -50,6 +49,13 @@ class MethodNotAllowedResource:
raise falcon.HTTPMethodNotAllowed(['PUT'])
class InternalServerErrorResource:
def on_get(self, req, resp):
raise falcon.HTTPInternalServerError('Excuse Us', 'Something went'
'boink!')
class TestHTTPError(helpers.TestSuite):
def prepare(self):
@@ -168,3 +174,9 @@ class TestHTTPError(helpers.TestSuite):
self.assertEqual(self.srmock.status, falcon.HTTP_405)
self.assertEqual(body, [])
self.assertIn(('Allow', 'PUT'), self.srmock.headers)
def test_500(self):
self.api.add_route('/500', InternalServerErrorResource())
body = self._simulate_request('/500')
self.assertEqual(self.srmock.status, falcon.HTTP_500)