"""Test the health logic.""" from unittest.mock import MagicMock from oto import status import sqlalchemy from marketing.logic import health from marketing.models import highlight def test_get_health_check(): """Testing getting the health check.""" response = health.get_health_check() assert response.message.get(highlight.Highlight.__tablename__) assert response.status == status.OK def test_get_invalid_health_check(monkeypatch): """Testing getting the health check.""" mock_session = MagicMock() mock_session.execute.side_effect = sqlalchemy.exc.SQLAlchemyError() mock_db_session = MagicMock(return_value=mock_session) monkeypatch.setattr(highlight.mysql, '_db_session', mock_db_session) response = health.get_health_check() assert response.status == status.INTERNAL_ERROR