Skip to content

Commit

Permalink
#36: WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
mwarkentin committed Jul 3, 2015
1 parent d20f196 commit c60309f
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 5 deletions.
14 changes: 12 additions & 2 deletions README.rst
Expand Up @@ -63,6 +63,11 @@ Quickstart
Features
--------

Human-friendly dashboard (new in 0.6.0)
***************************************

TBD

Token based authentication
**************************

Expand Down Expand Up @@ -129,8 +134,8 @@ querystring should be run, eg::

curl -XGET http://127.0.0.1:8080/watchman/?skip=watchman.checks.email

Django management command (new in ``django-watchman 0.5``)
**********************************************************
Django management command
*************************

You can also run your checks without starting the webserver and making requests.
This can be useful for testing your configuration before enabling a server,
Expand Down Expand Up @@ -167,6 +172,11 @@ Use ``-h`` to see a full list of options::

python manage.py watchman -h

X-Watchman-Version response header
**********************************

TBD

Available checks
----------------

Expand Down
18 changes: 18 additions & 0 deletions tests/test_views.py
Expand Up @@ -182,7 +182,16 @@ def test_response_when_login_required(self):
response = views.status(request)
self.assertEqual(response.status_code, 200)

def test_response_version_header_missing_by_default(self):
request = RequestFactory().get('/')
response = views.status(request)
self.assertFalse(response.has_header('X-Watchman-Version'))

@override_settings(WATCHMAN_VERSION_HEADER=True)
def test_response_version_header(self):
# Have to manually reload settings here because override_settings
# happens after self.setUp()
reload_settings()
request = RequestFactory().get('/')
response = views.status(request)
self.assertTrue(response.has_header('X-Watchman-Version'))
Expand All @@ -201,7 +210,16 @@ def test_dashboard_response_code(self):
response = views.dashboard(request)
self.assertEqual(response.status_code, 200)

def test_response_version_header_missing_by_default(self):
request = RequestFactory().get('/')
response = views.dashboard(request)
self.assertFalse(response.has_header('X-Watchman-Version'))

@override_settings(WATCHMAN_VERSION_HEADER=True)
def test_response_version_header(self):
# Have to manually reload settings here because override_settings
# happens after self.setUp()
reload_settings()
request = RequestFactory().get('/')
response = views.dashboard(request)
self.assertTrue(response.has_header('X-Watchman-Version'))
2 changes: 2 additions & 0 deletions watchman/settings.py
Expand Up @@ -19,3 +19,5 @@
DEFAULT_CHECKS = DEFAULT_CHECKS + PAID_CHECKS

WATCHMAN_CHECKS = getattr(settings, 'WATCHMAN_CHECKS', DEFAULT_CHECKS)

WATCHMAN_VERSION_HEADER = getattr(settings, 'WATCHMAN_VERSION_HEADER', False)
11 changes: 8 additions & 3 deletions watchman/views.py
Expand Up @@ -7,7 +7,7 @@
from django.utils.translation import ugettext as _

from jsonview.decorators import json_view
from watchman import __version__
from watchman import __version__, settings
from watchman.decorators import auth
from watchman.utils import get_checks

Expand Down Expand Up @@ -42,7 +42,10 @@ def status(request):
if len(response) == 0:
raise Http404(_('No checks found'))

return response, 200, {WATCHMAN_VERSION_HEADER: __version__}
if settings.WATCHMAN_VERSION_HEADER:
return response, 200, {WATCHMAN_VERSION_HEADER: __version__}
else:
return response


@auth
Expand Down Expand Up @@ -127,5 +130,7 @@ def dashboard(request):
'overall_status': overall_status
})

response[WATCHMAN_VERSION_HEADER] = __version__
if settings.WATCHMAN_VERSION_HEADER:
response[WATCHMAN_VERSION_HEADER] = __version__

return response

0 comments on commit c60309f

Please sign in to comment.