From 73e61aa1b30fe429b1a721dc31d75fae33f86f12 Mon Sep 17 00:00:00 2001 From: suegarner Date: Mon, 23 Sep 2024 14:40:50 +0100 Subject: [PATCH 1/5] FS-4446: Amend default column order for all funds except NSTF Rearranged the default order of the columns so that Score comes directly after Date submitted regardless whether there is a score entered or not. Previously Score and Score Subcriteria could be swapped depending on if the first row had been scored yet) --- db/queries/assessment_records/queries.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/queries/assessment_records/queries.py b/db/queries/assessment_records/queries.py index b52f791d..bd7968f9 100644 --- a/db/queries/assessment_records/queries.py +++ b/db/queries/assessment_records/queries.py @@ -576,8 +576,8 @@ def get_assessment_records_score_data_by_round_id(round_id, selected_fields=None default_fields = [ "Application ID", "Short ID", - "Score Subcriteria", "Score", + "Score Subcriteria", "Score Justification", "Score Date", "Score Time", From b114b19872b6c57ddc8f9afd9db875b0af62f539 Mon Sep 17 00:00:00 2001 From: suegarner Date: Tue, 24 Sep 2024 14:40:26 +0100 Subject: [PATCH 2/5] FS-4446: Rearranged default columns for NSTF Changed so that the report remains in the same order regardless if applications have been scored or not --- config/mappings/assessment_mapping_fund_round.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/mappings/assessment_mapping_fund_round.py b/config/mappings/assessment_mapping_fund_round.py index 466e1c79..e728b20f 100644 --- a/config/mappings/assessment_mapping_fund_round.py +++ b/config/mappings/assessment_mapping_fund_round.py @@ -261,8 +261,8 @@ "score_fields": { "Application ID", "Short ID", - "Score Subcriteria", "Score", + "Score Subcriteria", "Score Date", "Score Time", }, From 0297cab2e7ad10618c7f728f179401f22b72145d Mon Sep 17 00:00:00 2001 From: suegarner Date: Tue, 24 Sep 2024 17:24:46 +0100 Subject: [PATCH 3/5] FS-4446: Create test to check output tracker columns For the OUTPUT_TRACKER report, the test checks the column order in a report of unscored applications against the column order in a report of scored applications. The scored report will have more columns so we're comparing all the columns in the unscored report against the first x columns in scored report. --- tests/test_db_function.py | 52 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/tests/test_db_function.py b/tests/test_db_function.py index f87dba19..f8891771 100644 --- a/tests/test_db_function.py +++ b/tests/test_db_function.py @@ -507,6 +507,58 @@ def test_output_tracker_with_no_scores_data(seed_application_records, mocker): assert data["en_list"][0]["Risks to your project (document upload)"] == "sample1.doc" +@pytest.mark.apps_to_insert([test_input_data[0]]) +def test_output_tracker_columns_remain_same_for_scored_and_unscored_reports(seed_application_records, mocker): + mocker.patch( + "db.queries.assessment_records.queries.get_account_name", + return_value="Test user", + ) + + picked_row = get_assessment_record(seed_application_records[0]["application_id"]) + + no_scores = get_assessment_export_data( + picked_row.fund_id, + picked_row.round_id, + "OUTPUT_TRACKER", + { + "OUTPUT_TRACKER": { + "form_fields": { + "KAgrBz": {"en": {"title": "Project name"}}, + } + } + }, + ) + + application_id = picked_row.application_id + sub_criteria_id = "app-info" + + assessment_payload = { + "application_id": application_id, + "sub_criteria_id": sub_criteria_id, + "score": 5, + "justification": "great", + "user_id": "test", + } + create_score_for_app_sub_crit(**assessment_payload) + + with_scores = get_assessment_export_data( + picked_row.fund_id, + picked_row.round_id, + "OUTPUT_TRACKER", + { + "OUTPUT_TRACKER": { + "form_fields": { + "KAgrBz": {"en": {"title": "Project name"}}, + } + } + }, + ) + + with_scores_cols = list(with_scores['en_list'][0].keys())[:-5] + no_scores_cols = list(no_scores['en_list'][0].keys()) + assert with_scores_cols == no_scores_cols + + @pytest.mark.apps_to_insert([test_input_data[4]]) # taken from assessment store for cof r4w1 def test_get_cof_r4w1_export_data_en(seed_application_records): app_id = test_input_data[4]["id"] From 74e0173a0c2958303d847cc4c02834dba8710e15 Mon Sep 17 00:00:00 2001 From: suegarner Date: Thu, 26 Sep 2024 10:53:39 +0100 Subject: [PATCH 4/5] FS-4446 Remove magic number from unit test --- tests/test_db_function.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_db_function.py b/tests/test_db_function.py index f8891771..35b9a3c6 100644 --- a/tests/test_db_function.py +++ b/tests/test_db_function.py @@ -554,9 +554,9 @@ def test_output_tracker_columns_remain_same_for_scored_and_unscored_reports(seed }, ) - with_scores_cols = list(with_scores['en_list'][0].keys())[:-5] no_scores_cols = list(no_scores['en_list'][0].keys()) - assert with_scores_cols == no_scores_cols + with_scores_cols = list(with_scores['en_list'][0].keys())[:len(no_scores_cols)] + assert no_scores_cols == with_scores_cols @pytest.mark.apps_to_insert([test_input_data[4]]) # taken from assessment store for cof r4w1 From 56981853183446a4763ca592d0e9b0c45125baa3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 26 Sep 2024 11:18:13 +0000 Subject: [PATCH 5/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_db_function.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_db_function.py b/tests/test_db_function.py index 35b9a3c6..b166e1bc 100644 --- a/tests/test_db_function.py +++ b/tests/test_db_function.py @@ -553,10 +553,10 @@ def test_output_tracker_columns_remain_same_for_scored_and_unscored_reports(seed } }, ) - - no_scores_cols = list(no_scores['en_list'][0].keys()) - with_scores_cols = list(with_scores['en_list'][0].keys())[:len(no_scores_cols)] - assert no_scores_cols == with_scores_cols + + no_scores_cols = list(no_scores["en_list"][0].keys()) + with_scores_cols = list(with_scores["en_list"][0].keys())[: len(no_scores_cols)] + assert no_scores_cols == with_scores_cols @pytest.mark.apps_to_insert([test_input_data[4]]) # taken from assessment store for cof r4w1