test_health.py 1.1 KB

123456789101112131415161718192021222324252627282930
  1. # Copyright 2020 The Matrix.org Foundation C.I.C.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. from http import HTTPStatus
  15. from synapse.rest.health import HealthResource
  16. from tests import unittest
  17. class HealthCheckTests(unittest.HomeserverTestCase):
  18. def create_test_resource(self) -> HealthResource:
  19. # replace the JsonResource with a HealthResource.
  20. return HealthResource()
  21. def test_health(self) -> None:
  22. channel = self.make_request("GET", "/health", shorthand=False)
  23. self.assertEqual(channel.code, HTTPStatus.OK)
  24. self.assertEqual(channel.result["body"], b"OK")