Skip to content

Commit

Permalink
Improving coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
seocam committed Jan 8, 2015
1 parent 3cadb77 commit 169d1d9
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion tests/test_transformer.py
Expand Up @@ -38,13 +38,31 @@ def test_disable_request_header(self):
def test_disable_response_header(self):
request = self.factory.get('/')
headers = {'Content-Type': 'text/html', 'X-Diazo-Off': 'true'}
urlopen_mock = get_urlopen_mock()
urlopen_mock = get_urlopen_mock(headers=headers)

with patch(URLOPEN, urlopen_mock):
response = CustomProxyView.as_view()(request, '/')

self.assertEqual(response.content, b'Mock')

def test_x_diazo_off_false_on_response(self):
request = self.factory.get('/')
headers = {'Content-Type': 'text/html', 'X-Diazo-Off': 'false'}
urlopen_mock = get_urlopen_mock(headers=headers)

with patch(URLOPEN, urlopen_mock):
response = CustomProxyView.as_view()(request, '/')

self.assertNotIn(response.content, b'Mock')

def test_x_diazo_off_invalid(self):
request = self.factory.get('/')
headers = {'Content-Type': 'text/html', 'X-Diazo-Off': 'nopz'}
urlopen_mock = get_urlopen_mock(headers=headers)

with patch(URLOPEN, urlopen_mock), self.assertRaises(ValueError):
response = CustomProxyView.as_view()(request, '/')

def test_ajax_request(self):
request = self.factory.get('/', HTTP_X_REQUESTED_WITH='XMLHttpRequest')

Expand Down

0 comments on commit 169d1d9

Please sign in to comment.