Skip to content

Commit

Permalink
Fix and add more 360/tests.py
Browse files Browse the repository at this point in the history
  • Loading branch information
BibianaC authored and robredpath committed Jun 7, 2019
1 parent ca96eb0 commit a49d0dd
Showing 1 changed file with 45 additions and 34 deletions.
79 changes: 45 additions & 34 deletions cove_360/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 "
Expand Down Expand Up @@ -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 "
Expand All @@ -359,42 +359,26 @@
"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 "
"to see who else has given grants to the same recipient, even if they’re "
"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 "
"to see who else has given grants to the same recipient, even if they’re "
"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 "
Expand All @@ -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 "
Expand All @@ -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 "
Expand Down Expand Up @@ -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

0 comments on commit a49d0dd

Please sign in to comment.