Skip to content
This repository has been archived by the owner on Nov 29, 2024. It is now read-only.

Commit

Permalink
update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
RamuniN committed Oct 19, 2023
1 parent 02d8451 commit 33b5256
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 12 deletions.
4 changes: 3 additions & 1 deletion db/queries/feedback/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
45 changes: 34 additions & 11 deletions tests/test_all_feedbacks.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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": "[email protected]"}],
}
],
),
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",
Expand Down Expand Up @@ -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",
Expand All @@ -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
Expand Down

0 comments on commit 33b5256

Please sign in to comment.