-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/bare status #114
Feature/bare status #114
Changes from all commits
38b9253
e89d26e
4847df7
446c889
ae48537
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
from django.conf.urls import include, url | ||
from django.contrib import admin | ||
import watchman.views | ||
|
||
|
||
urlpatterns = [ | ||
url(r'^admin/', include(admin.site.urls)), | ||
url(r'^watchman/', include('watchman.urls')), | ||
url(r'^watchman/bare/', watchman.views.bare_status, name='bare_status'), | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -355,6 +355,55 @@ def test_returns_pong(self): | |
self.assertEqual(response['Content-Type'], 'text/plain') | ||
|
||
|
||
class TestBareStatus(unittest.TestCase): | ||
def setUp(self): | ||
# Ensure that every test executes with separate settings | ||
reload_settings() | ||
|
||
def test_bare_status_success(self): | ||
request = RequestFactory().get('/') | ||
response = views.bare_status(request) | ||
self.assertEqual(response.status_code, 200) | ||
self.assertEqual(response.content.decode(), '') | ||
|
||
@patch('watchman.checks._check_databases') | ||
@override_settings(WATCHMAN_ERROR_CODE=503) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add another test that the default error code for the bare status view will be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 657f135 |
||
def test_bare_status_error(self, patched_check_databases): | ||
reload_settings() | ||
# Fake a DB error, ensure we get our error code | ||
patched_check_databases.return_value = [{ | ||
"foo": { | ||
"ok": False, | ||
"error": "Fake DB Error", | ||
"stacktrace": "Fake DB Stack Trace", | ||
}, | ||
}] | ||
request = RequestFactory().get('/', data={ | ||
'check': 'watchman.checks.databases', | ||
}) | ||
response = views.bare_status(request) | ||
self.assertEqual(response.status_code, 503) | ||
self.assertEqual(response.content.decode(), '') | ||
|
||
@patch('watchman.checks._check_databases') | ||
def test_bare_status_default_error(self, patched_check_databases): | ||
reload_settings() | ||
# Fake a DB error, ensure we get our error code | ||
patched_check_databases.return_value = [{ | ||
"foo": { | ||
"ok": False, | ||
"error": "Fake DB Error", | ||
"stacktrace": "Fake DB Stack Trace", | ||
}, | ||
}] | ||
request = RequestFactory().get('/', data={ | ||
'check': 'watchman.checks.databases', | ||
}) | ||
response = views.bare_status(request) | ||
self.assertEqual(response.status_code, 500) | ||
self.assertEqual(response.content.decode(), '') | ||
|
||
|
||
class TestEmailCheck(DjangoTestCase): | ||
def setUp(self): | ||
# Ensure that every test executes with separate settings | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a
0.15.0 (Unreleased)
heading to the history file and add a bullet for this feature?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 657f135