From a49d0dd0346ed2b178d1946bc744d61ba0ea4c55 Mon Sep 17 00:00:00 2001 From: Bibiana Cristofol Amat Date: Fri, 22 Feb 2019 16:12:45 +0000 Subject: [PATCH] Fix and add more 360/tests.py --- cove_360/tests.py | 79 +++++++++++++++++++++++++++-------------------- 1 file changed, 45 insertions(+), 34 deletions(-) diff --git a/cove_360/tests.py b/cove_360/tests.py index 7bbcf77ef..df20b9071 100644 --- a/cove_360/tests.py +++ b/cove_360/tests.py @@ -6,7 +6,7 @@ from django.core.files.uploadedfile import UploadedFile from . lib.schema import Schema360 -from . lib.threesixtygiving import run_additional_checks +from . lib.threesixtygiving import run_extra_checks, TEST_CLASSES from cove.input.models import SuppliedData # Source is cove_360/fixtures/fundingproviders-grants_fixed_2_grants.json @@ -292,7 +292,7 @@ } -RESULTS = [ +ADDITIONAL_CHECKS_RESULTS = [ ({'heading': "1 grant does not have recipient organisation location information", 'message': ("Your data is missing information about the geographic location of recipient " "organisations; either Recipient Org:Postal Code or Recipient Org:Location:Geographic Code " @@ -350,7 +350,7 @@ ] -OTHER_RESULTS = [ +QUALITY_ACCURACY_CHECKS_RESULTS = [ ({'heading': "1 grant has a value of £0", 'message': ("It’s worth taking a look at these grants and deciding if " "they should be published. It’s unusual to have grants of £0, but " @@ -359,23 +359,7 @@ "so consider adding an explanation to the description of the grant.")}, ['grants/0/amountAwarded'], [{'sheet': 'grants', 'letter': 'Q', 'row_number': 2, 'header': 'Amount Awarded'}]), - ({'heading': "1 grant has a Recipient Org:Identifier that starts '360G-'", - 'message': ("If the grant is to a recipient organisation that has an external " - "identifier (such as a charity or company number), then this should " - "be used instead. Using external identifiers helps people using your " - "data to match it up against other data - for example to see who else " - "has given grants to the same recipient, even if they’re known by a " - "different name. If no external identifier can be used, then you can " - "ignore this notice.")}, - ['grants/0/recipientOrganization/0/id'], - [{'sheet': 'grants', 'letter': 'J', 'row_number': 2, 'header': 'Recipient Org:Identifier'}]), - ({'heading': "1 grant has a Funding Org:Identifier that starts '360G-'", - 'message': ("If the grant is from a funding organisation that has an external identifier " - "(such as a charity or company number), then this should be used instead. " - "If no other identifier can be used, then you can ignore this notice.")}, - ['grants/1/fundingOrganization/0/id'], - [{'sheet': 'grants', 'letter': 'V', 'row_number': 3, 'header': 'Funding Org:Identifier'}]), - ({'heading': ("1 grant has a Recipient Org:Identifier that does not draw from " + ({'heading': ("1 grant has a Funding Org:Identifier that does not draw from " "a recognised register."), 'message': ("Using external identifiers (such as a charity or company number) helps " "people using your data to match it up against other data - for example " @@ -383,9 +367,9 @@ "known by a different name. If the data describes lots of grants to " "organisations that don’t have such identifiers, or grants to individuals, " "then you can ignore this notice.")}, - ['grants/1/recipientOrganization/0/id'], - [{'sheet': 'grants', 'letter': 'J', 'row_number': 3, 'header': 'Recipient Org:Identifier'}]), - ({'heading': ("1 grant has a Funding Org:Identifier that does not draw from " + ['grants/0/fundingOrganization/0/id'], + [{'sheet': 'grants', 'letter': 'V', 'row_number': 2, 'header': 'Funding Org:Identifier'}]), + ({'heading': ("1 grant has a Recipient Org:Identifier that does not draw from " "a recognised register."), 'message': ("Using external identifiers (such as a charity or company number) helps " "people using your data to match it up against other data - for example " @@ -393,8 +377,8 @@ "known by a different name. If the data describes lots of grants to " "organisations that don’t have such identifiers, or grants to individuals, " "then you can ignore this notice.")}, - ['grants/0/fundingOrganization/0/id'], - [{'sheet': 'grants', 'letter': 'V', 'row_number': 2, 'header': 'Funding Org:Identifier'}]), + ['grants/1/recipientOrganization/0/id'], + [{'sheet': 'grants', 'letter': 'J', 'row_number': 3, 'header': 'Recipient Org:Identifier'}]), ({'heading': ("1 grant has a value provided in the Recipient Org: Charity Number column " "that doesn’t look like a charity number"), 'message': ("Common causes of this are missing leading digits, typos or incorrect " @@ -407,13 +391,6 @@ "values being entered into this field.")}, ['grants/0/recipientOrganization/0/companyNumber'], [{'sheet': 'grants', 'letter': 'L', 'row_number': 2, 'header': 'Recipient Org:Company Number'}]), - ({'heading': "1 grant does not have either a Recipient Org:Company Number or a Recipient Org:Charity Number", - 'message': ("Providing one or both of these, if possible, makes it easier for users " - "to join up your data with other data sources to provide better insight " - "into grantmaking. If your grants are to organisations that don’t have UK " - "Company or UK Charity numbers, then you can ignore this notice.")}, - ['grants/2/recipientOrganization/0/id'], - [{'sheet': 'grants', 'letter': 'J', 'row_number': 4, 'header': 'Recipient Org:Identifier'}]), ({'heading': "There are 3 different funding organisation IDs listed", 'message': ("If you are expecting to be publishing data for multiple funders then " "you can ignore this notice. If you are only publishing for a " @@ -422,7 +399,33 @@ ['grants/0/fundingOrganization/0/id', 'grants/1/fundingOrganization/0/id', 'grants/2/fundingOrganization/0/id'], [{'sheet': 'grants', 'letter': 'V', 'row_number': 2, 'header': 'Funding Org:Identifier'}, {'sheet': 'grants', 'letter': 'V', 'row_number': 3, 'header': 'Funding Org:Identifier'}, - {'sheet': 'grants', 'letter': 'V', 'row_number': 4, 'header': 'Funding Org:Identifier'}]), + {'sheet': 'grants', 'letter': 'V', 'row_number': 4, 'header': 'Funding Org:Identifier'}]) +] + +USEFULNESS_CHECKS_RESULTS = [ + ({'heading': "1 grant has a Recipient Org:Identifier that starts '360G-'", + 'message': ("If the grant is to a recipient organisation that has an external " + "identifier (such as a charity or company number), then this should " + "be used instead. Using external identifiers helps people using your " + "data to match it up against other data - for example to see who else " + "has given grants to the same recipient, even if they’re known by a " + "different name. If no external identifier can be used, then you can " + "ignore this notice.")}, + ['grants/0/recipientOrganization/0/id'], + [{'sheet': 'grants', 'letter': 'J', 'row_number': 2, 'header': 'Recipient Org:Identifier'}]), + ({'heading': "1 grant has a Funding Org:Identifier that starts '360G-'", + 'message': ("If the grant is from a funding organisation that has an external identifier " + "(such as a charity or company number), then this should be used instead. " + "If no other identifier can be used, then you can ignore this notice.")}, + ['grants/1/fundingOrganization/0/id'], + [{'sheet': 'grants', 'letter': 'V', 'row_number': 3, 'header': 'Funding Org:Identifier'}]), + ({'heading': "1 grant does not have either a Recipient Org:Company Number or a Recipient Org:Charity Number", + 'message': ("Providing one or both of these, if possible, makes it easier for users " + "to join up your data with other data sources to provide better insight " + "into grantmaking. If your grants are to organisations that don’t have UK " + "Company or UK Charity numbers, then you can ignore this notice.")}, + ['grants/2/recipientOrganization/0/id'], + [{'sheet': 'grants', 'letter': 'J', 'row_number': 4, 'header': 'Recipient Org:Identifier'}]), ({'heading': "1 grant does not have Last Modified information", 'message': "Last Modified shows the date and time when information about a grant was " "last updated in your file. Including this information allows data users to " @@ -540,4 +543,12 @@ def test_schema_360(): def test_additional_checks(): - assert run_additional_checks(GRANTS, SOURCE_MAP) == RESULTS + assert run_extra_checks(GRANTS, SOURCE_MAP, TEST_CLASSES['additional']) == ADDITIONAL_CHECKS_RESULTS + + +def test_quality_accuracy_checks(): + assert run_extra_checks(GRANTS, SOURCE_MAP, TEST_CLASSES['quality_accuracy']) == QUALITY_ACCURACY_CHECKS_RESULTS + + +def test_usefulness_checks(): + assert run_extra_checks(GRANTS, SOURCE_MAP, TEST_CLASSES['usefulness']) == USEFULNESS_CHECKS_RESULTS