diff --git a/datastore/data_quality/quality_data.py b/datastore/data_quality/quality_data.py index 23abc2f..93ffaf7 100644 --- a/datastore/data_quality/quality_data.py +++ b/datastore/data_quality/quality_data.py @@ -106,16 +106,19 @@ def create(grants): ], } + # Sort recipient / funder org-id lists to be deterministic for tests aggregates = { "count": cove_results["grants_aggregates"]["count"], "recipient_organisations": list( - cove_results["grants_aggregates"]["distinct_recipient_org_identifier"] + sorted( + cove_results["grants_aggregates"]["distinct_recipient_org_identifier"] + ) ), "recipient_individuals": cove_results["grants_aggregates"][ "recipient_individuals_count" ], "funders": list( - cove_results["grants_aggregates"]["distinct_funding_org_identifier"] + sorted(cove_results["grants_aggregates"]["distinct_funding_org_identifier"]) ), "max_award_date": cove_results["grants_aggregates"]["max_award_date"], "min_award_date": cove_results["grants_aggregates"]["min_award_date"], @@ -432,7 +435,6 @@ def get_pc_publishers_publishing_in_last(self, delta): ) def get_pc_publishers_with_recipient_ext_org(self): - ret = {} total_publishers = self.get_total_publishers() @@ -468,7 +470,6 @@ def get_pc_publishers_with_recipient_ext_org(self): return ret def get_total_grants_awarded_in_last_ten_years(self): - this_year_int = datetime.now().year award_years = {} @@ -485,7 +486,6 @@ def get_total_grants_awarded_in_last_ten_years(self): return award_years def get_pc_publishers_with_grants_awarded_in_last_ten_years(self): - this_year_int = datetime.now().year award_years = {} diff --git a/datastore/tests/test_quality_data.py b/datastore/tests/test_quality_data.py index 9de10a7..082a774 100644 --- a/datastore/tests/test_quality_data.py +++ b/datastore/tests/test_quality_data.py @@ -32,7 +32,9 @@ def test_create_sourcefile_publisher_quality_data(self): expected_sourcefile_aggregate = { "count": 5, - "recipient_organisations": ["360G-example-a", "360G-example-nonprimary"], + "recipient_organisations": sorted( + ["360G-example-a", "360G-example-nonprimary"] + ), "recipient_individuals": 0, "funders": ["GB-example-b"], "max_award_date": "2019-10-03",