summaryrefslogtreecommitdiff
path: root/service/test/unit
diff options
context:
space:
mode:
authorBlake Williams <github@qzxj.net>2016-06-02 19:04:42 +1000
committerFelix Hammerl <felix.hammerl@gmail.com>2016-06-02 11:04:42 +0200
commit460074b11ac9171cb7b260e1ffc01e040105b3e5 (patch)
treede20fc8a69d96a903d05d5ffca2b3fff97fd6a7e /service/test/unit
parent45adea860ceaf23cfabdaf6a22d13c4650550bb3 (diff)
RootResource should return 503 during startup (#699)
Return 503 code while RootResource is in MODE_STARTUP
Diffstat (limited to 'service/test/unit')
-rw-r--r--service/test/unit/resources/test_root_resource.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/service/test/unit/resources/test_root_resource.py b/service/test/unit/resources/test_root_resource.py
index f2d7a951..b90e89eb 100644
--- a/service/test/unit/resources/test_root_resource.py
+++ b/service/test/unit/resources/test_root_resource.py
@@ -68,6 +68,21 @@ class TestRootResource(unittest.TestCase):
self.root_resource._mode = MODE_RUNNING
self._test_should_renew_xsrf_cookie()
+ def test_should_unavailable_child_resource_during_startup(self):
+ self.root_resource._mode = MODE_STARTUP
+
+ request = DummyRequest(['/child'])
+ request.getCookie = MagicMock(return_value='irrelevant -- stubbed')
+
+ d = self.web.get(request)
+
+ def assert_unavailable(_):
+ self.assertEqual(503, request.responseCode)
+ self.assertEqual("Service Unavailable", request.written[0])
+
+ d.addCallback(assert_unavailable)
+ return d
+
def _mock_ajax_csrf(self, request, csrf_token):
request.requestHeaders.setRawHeaders('x-requested-with', ['XMLHttpRequest'])
request.requestHeaders.setRawHeaders('x-xsrf-token', [csrf_token])
@@ -92,6 +107,7 @@ class TestRootResource(unittest.TestCase):
request.getCookie = MagicMock(return_value='irrelevant -- stubbed')
self.root_resource._child_resources.add('features', FeaturesResource())
+ self.root_resource._mode = MODE_RUNNING
d = self.web.get(request)