From 33b52561f113e3e1feac0997ff0988ba64881d9d Mon Sep 17 00:00:00 2001 From: RamuniN Date: Thu, 19 Oct 2023 13:41:02 +0100 Subject: [PATCH] update unit tests --- db/queries/feedback/queries.py | 4 ++- tests/test_all_feedbacks.py | 45 +++++++++++++++++++++++++--------- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/db/queries/feedback/queries.py b/db/queries/feedback/queries.py index bc379d10..d36d4b92 100644 --- a/db/queries/feedback/queries.py +++ b/db/queries/feedback/queries.py @@ -125,7 +125,9 @@ def retrieve_all_feedbacks_and_surveys(fund_id, round_id, status): # extract applicant email & organisation try: result = map_application_key_fields( - applicant_serialiser.dump(application), mapping_report.mapping, round_id + applicant_serialiser.dump(application), + mapping_report.mapping, + mapping_report.round_id, ) applicant_email = result["applicant_email"] applicant_organisation = result["organisation_name"] diff --git a/tests/test_all_feedbacks.py b/tests/test_all_feedbacks.py index 974dfe32..f8cb19a0 100644 --- a/tests/test_all_feedbacks.py +++ b/tests/test_all_feedbacks.py @@ -1,4 +1,7 @@ import pytest +from config.key_report_mappings.cof_r3w2_key_report_mapping import ( + COF_R3W2_KEY_REPORT_MAPPING, +) from db.models import Applications from db.models import EndOfApplicationSurveyFeedback from db.models import Feedback @@ -13,7 +16,30 @@ applications = [ Applications( id="app_1", - forms=[Forms()], + forms=[ + Forms( + name="applicant-information-cof-r3-w2", + json=[ + { + "questions": "Lead contact details", + "fields": [{"key": "NlHSBg", "answer": "test@test.com"}], + } + ], + ), + Forms( + name="organisation-information-cof-r3-w2", + json=[ + { + "questions": "organisation information", + "fields": [ + {"key": "WWWWxy", "answer": "Ref1234"}, + {"key": "YdtlQZ", "answer": "OrgName"}, + {"key": "lajFtB", "answer": "Non-Profit"}, + ], + } + ], + ), + ], feedbacks=[ Feedback( section_id="62", @@ -48,20 +74,13 @@ @pytest.mark.parametrize( - "app_sections,applications", + "app_sections,applications,report_mapping", [ - ( - [ - app_sections, - applications, - ] - ), + ([app_sections, applications, COF_R3W2_KEY_REPORT_MAPPING]), ], ) def test_retrieve_all_feedbacks_and_surveys( - mocker, - app_sections, - applications, + mocker, app_sections, applications, report_mapping ): mocker.patch( "db.queries.feedback.queries.get_application_sections", @@ -71,6 +90,10 @@ def test_retrieve_all_feedbacks_and_surveys( "db.queries.feedback.queries.get_applications", return_value=applications, ) + mocker.patch( + "db.queries.feedback.queries.get_report_mapping_for_round", + return_value=report_mapping, + ) result = retrieve_all_feedbacks_and_surveys("test_fund", "test_round", "SUBMITTED") assert "sections_feedback" in result