Skip to content

Commit

Permalink
feat: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
panteparak committed Oct 21, 2024
1 parent af10d61 commit 339aa06
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/test_db_heartbeat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import unittest

from health_check.contrib.db_heartbeat import DatabaseHeartBeatCheck
from health_check.exceptions import ServiceUnavailable


class TestDatabaseHeartBeatCheck(unittest.TestCase):

def test_check_status_success(self):
health_check = DatabaseHeartBeatCheck()
try:
health_check.check_status() # Should pass without exceptions
except Exception as e:
self.fail(f"check_status() raised an exception unexpectedly: {e}")

def test_check_status_unexpected_result(self):
health_check = DatabaseHeartBeatCheck()
with self.assertRaises(ServiceUnavailable):
health_check.check_status()


if __name__ == "__main__":
unittest.main()
1 change: 1 addition & 0 deletions tests/testapp/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"health_check.contrib.migrations",
"health_check.contrib.celery_ping",
"health_check.contrib.s3boto_storage",
"health_check.contrib.db_heartbeat",
"tests",
)

Expand Down

0 comments on commit 339aa06

Please sign in to comment.