Update tests to reflect current behavior

This commit is contained in:
David Cramer 2013-01-21 16:10:51 -08:00
parent 3caf9083b5
commit 5586e865f2
2 changed files with 7 additions and 5 deletions

View File

@ -38,6 +38,7 @@ def pytest_configure(config):
BROKER_USER="guest",
BROKER_PASSWORD="guest",
BROKER_VHOST="/",
SENTRY_ALLOW_ORIGIN='*',
CELERY_ALWAYS_EAGER=True,
TEMPLATE_DEBUG=True,
TEMPLATE_DIRS=[os.path.join(where_am_i, 'tests', 'contrib', 'django', 'templates')],

View File

@ -558,15 +558,16 @@ class ReportViewTest(TestCase):
def setUp(self):
self.path = reverse('raven-report')
def test_does_not_allow_get(self):
resp = self.client.get(self.path)
self.assertEquals(resp.status_code, 405)
@mock.patch('raven.contrib.django.views.is_valid_origin')
def test_calls_is_valid_origin_with_header(self, is_valid_origin):
self.client.post(self.path, HTTP_ORIGIN='http://example.com')
is_valid_origin.assert_called_once_with('http://example.com')
@mock.patch('raven.contrib.django.views.is_valid_origin')
def test_calls_is_valid_origin_with_header_as_get(self, is_valid_origin):
self.client.get(self.path, HTTP_ORIGIN='http://example.com')
is_valid_origin.assert_called_once_with('http://example.com')
@mock.patch('raven.contrib.django.views.is_valid_origin', mock.Mock(return_value=False))
def test_fails_on_invalid_origin(self):
resp = self.client.post(self.path, HTTP_ORIGIN='http://example.com')
@ -577,7 +578,7 @@ class ReportViewTest(TestCase):
resp = self.client.options(self.path, HTTP_ORIGIN='http://example.com')
self.assertEquals(resp.status_code, 200)
self.assertEquals(resp['Access-Control-Allow-Origin'], 'http://example.com')
self.assertEquals(resp['Access-Control-Allow-Methods'], 'POST, OPTIONS')
self.assertEquals(resp['Access-Control-Allow-Methods'], 'GET, POST, OPTIONS')
@mock.patch('raven.contrib.django.views.is_valid_origin', mock.Mock(return_value=True))
def test_missing_data(self):