From 905c4c881c71598962fdc99eeeb1e8778393445a Mon Sep 17 00:00:00 2001 From: lambeb <141648830+lambeb@users.noreply.github.com> Date: Mon, 11 Nov 2024 15:55:34 +0000 Subject: [PATCH] Added test where respondent data has no value at all --- tests/services/test_mi_hub_reports_service.py | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/tests/services/test_mi_hub_reports_service.py b/tests/services/test_mi_hub_reports_service.py index f3e8abf..dcd8bb9 100644 --- a/tests/services/test_mi_hub_reports_service.py +++ b/tests/services/test_mi_hub_reports_service.py @@ -1,6 +1,7 @@ from unittest.mock import create_autospec import pytest +from py._code.code import ExceptionInfo from functions.google_storage_functions import GoogleStorage from models.mi_hub_call_history_model import MiHubCallHistory @@ -184,4 +185,40 @@ def test_deliver_mi_hub_reports_with_some_data_empty_returns_expected_string( ) # assert - assert result == f"Done - {QUESTIONNAIRE_NAME}" \ No newline at end of file + assert result == f"Done - {QUESTIONNAIRE_NAME}" + + + +@pytest.fixture +def mock_mi_hub_respondent_data_missing(): + return [ + MiHubRespondentData( + serial_number=None, + outcome_code=None, + date_completed=None, + interviewer=None, + mode=None, + postcode=None, + gender=None, + date_of_birth=None, + age=None, + ), + ] + + +def test_deliver_mi_hub_reports_with_no_respondent_data( + mock_mi_hub_call_history, mock_mi_hub_respondent_data_missing +): + # arrange + mock_google_storage = create_autospec(GoogleStorage) + + # act + result = DeliverMiHubReportsService.upload_mi_hub_reports_to_gcp( + questionnaire_name=QUESTIONNAIRE_NAME, + mi_hub_call_history=mock_mi_hub_call_history, + mi_hub_respondent_data=mock_mi_hub_respondent_data_missing, + google_storage=mock_google_storage, + ) + + # assert + assert result == f"Done - {QUESTIONNAIRE_NAME}"