diff --git a/swift/common/middleware/healthcheck.py b/swift/common/middleware/healthcheck.py index cfb0b8a0ba..f9f6b24ea9 100644 --- a/swift/common/middleware/healthcheck.py +++ b/swift/common/middleware/healthcheck.py @@ -35,11 +35,11 @@ class HealthCheckMiddleware(object): def GET(self, req): """Returns a 200 response with "OK" in the body.""" - return Response(request=req, body="OK", content_type="text/plain") + return Response(request=req, body=b"OK", content_type="text/plain") def DISABLED(self, req): """Returns a 503 response with "DISABLED BY FILE" in the body.""" - return Response(request=req, status=503, body="DISABLED BY FILE", + return Response(request=req, status=503, body=b"DISABLED BY FILE", content_type="text/plain") def __call__(self, env, start_response): diff --git a/test/unit/common/middleware/test_healthcheck.py b/test/unit/common/middleware/test_healthcheck.py index 3f95c6b2a8..34e29e424b 100644 --- a/test/unit/common/middleware/test_healthcheck.py +++ b/test/unit/common/middleware/test_healthcheck.py @@ -51,21 +51,21 @@ class TestHealthCheck(unittest.TestCase): app = self.get_app(FakeApp(), {}) resp = app(req.environ, self.start_response) self.assertEqual(['200 OK'], self.got_statuses) - self.assertEqual(resp, ['OK']) + self.assertEqual(resp, [b'OK']) - def test_healtcheck_pass(self): + def test_healthcheck_pass(self): req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'}) app = self.get_app(FakeApp(), {}) resp = app(req.environ, self.start_response) self.assertEqual(['200 OK'], self.got_statuses) - self.assertEqual(resp, ['FAKE APP']) + self.assertEqual(resp, [b'FAKE APP']) def test_healthcheck_pass_not_disabled(self): req = Request.blank('/healthcheck', environ={'REQUEST_METHOD': 'GET'}) app = self.get_app(FakeApp(), {}, disable_path=self.disable_path) resp = app(req.environ, self.start_response) self.assertEqual(['200 OK'], self.got_statuses) - self.assertEqual(resp, ['OK']) + self.assertEqual(resp, [b'OK']) def test_healthcheck_pass_disabled(self): open(self.disable_path, 'w') @@ -73,7 +73,7 @@ class TestHealthCheck(unittest.TestCase): app = self.get_app(FakeApp(), {}, disable_path=self.disable_path) resp = app(req.environ, self.start_response) self.assertEqual(['503 Service Unavailable'], self.got_statuses) - self.assertEqual(resp, ['DISABLED BY FILE']) + self.assertEqual(resp, [b'DISABLED BY FILE']) if __name__ == '__main__': diff --git a/tox.ini b/tox.ini index 747e3e077c..c8baa7283c 100644 --- a/tox.ini +++ b/tox.ini @@ -38,6 +38,7 @@ commands = test/unit/cli/test_ringbuilder.py \ test/unit/common/middleware/test_catch_errors.py \ test/unit/common/middleware/test_gatekeeper.py \ + test/unit/common/middleware/test_healthcheck.py \ test/unit/common/middleware/test_proxy_logging.py \ test/unit/common/ring \ test/unit/common/test_constraints.py \