import falcon import pytest from falcon import testing from dapd_transformation_service.entities.worker_control import WorkerHealthResponseEnum @pytest.mark.parametrize(['worker_health', 'status_code'], [ (WorkerHealthResponseEnum.OK, falcon.HTTP_200), (WorkerHealthResponseEnum.INVALID_RESPONSE, falcon.HTTP_500), (WorkerHealthResponseEnum.DB_DOWN, falcon.HTTP_500), (WorkerHealthResponseEnum.TIMEOUT, falcon.HTTP_500), ]) # yapf: disable def test_health_check(client, mocker, worker_health, status_code): mocker.patch( 'dapd_transformation_service.services.health_check.HealthCheckService.' 'request_worker_health', return_value=worker_health ) expected = {'status': worker_health} result: testing.Result = client.simulate_get('/api/v1/health/') assert result.status == status_code assert result.json == expected