Skip to content

Commit

Permalink
[#834] iati_ruleset: fix broken test
Browse files Browse the repository at this point in the history
  • Loading branch information
edugomez committed Oct 3, 2017
1 parent 72e68e4 commit 3b3e394
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 24 deletions.
58 changes: 53 additions & 5 deletions cove_iati/fixtures/iati_openag_tag.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<transaction-date iso-date="2017-01-01"/>
<value value-date="2017-01-01" >40</value>
</transaction>
<openag:tag vocabulary="99" vocabulary-uri="http://aims.fao.org/aos/agrovoc/" code="c_4397">
<openag:tag vocabulary-uri="http://aims.fao.org/aos/agrovoc/" code="c_4397">
<narrative xml:lang="en">Livestock</narrative>
</openag:tag>
</iati-activity>
Expand All @@ -41,7 +41,7 @@
<activity-status code="3"/><activity-date type="2" iso-date="2017-01-01"/>
<recipient-country code="TZ" percentage="100"/>
<location>
<location-id />
<location-id vocabulary="G1" />
<name>
<narrative>Ilala District, Dar es Salaam, Tanzania TZ</narrative>
</name>
Expand Down Expand Up @@ -76,7 +76,7 @@
<transaction-date iso-date="2017-01-01"/>
<value value-date="2017-01-01">40</value>
</transaction>
<openag:tag vocabulary="90" vocabulary-uri="http://bad.org" code="c_4397">
<openag:tag vocabulary="98" vocabulary-uri="http://bad.org" code="c_4397">
<narrative xml:lang="en">Livestock</narrative>
</openag:tag>
</iati-activity>
Expand All @@ -91,7 +91,7 @@
<recipient-country code="AF" percentage="30"/>
<location>
<location-reach code="1"/>
<location-id vocabulary="G1" code="159239" />
<location-id code="159239" />
<name>
<narrative>Ilala District, Dar es Salaam, Tanzania TZ</narrative>
</name>
Expand Down Expand Up @@ -126,7 +126,7 @@
<transaction-date iso-date="2017-01-01"/>
<value value-date="2017-01-01">40</value>
</transaction>
<openag:tag>
<openag:tag vocabulary="01" vocabulary-uri="http://aims.fao.org/aos/agrovoc/" code="c_4397">
<narrative xml:lang="en">Livestock</narrative>
</openag:tag>
</iati-activity>
Expand Down Expand Up @@ -175,5 +175,53 @@
<transaction-date iso-date="2017-01-01"/>
<value value-date="2017-01-01">40</value>
</transaction>
<openag:tag vocabulary="98" vocabulary-uri="http://aims.fao.org/aos/agrovoc/">
<narrative xml:lang="en">Livestock</narrative>
</openag:tag>
</iati-activity>
<iati-activity>
<iati-identifier>EE-DDD-789789-EE789</iati-identifier>
<reporting-org ref="TZ-BRLA-90000" type="40"><narrative>Reporting Organisation D</narrative></reporting-org>
<title><narrative>A title</narrative></title>
<description><narrative>A description</narrative></description>
<participating-org role="1" ref="TZ-BRLA-100000"/>
<activity-status code="3"/><activity-date type="start-actual" iso-date="2017-01-01"/>
<recipient-country code="AF" percentage="30"/>
<location>
<location-reach code="1"/>
<name>
<narrative>Ilala District, Dar es Salaam, Tanzania TZ</narrative>
</name>
<description>
<narrative>Ilala District is one of three districts in Dar es Salaam</narrative>
</description>
<administrative vocabulary="G1" level="2" code="159239"/>
<point srsName="http://www.opengis.net/def/crs/EPSG/0/4326">
<pos>-6.91805, 39.16254</pos>
</point>
<exactness code="1"/>
<location-class code="1"/>
<feature-designation code="ADM2"/>
</location>
<transaction>
<transaction-type code="2"/>
<transaction-date iso-date="2017-01-01"/>
<value value-date="2012-01-01">10</value>
</transaction>
<transaction>
<transaction-type code="3"/>
<transaction-date iso-date="2017-01-01"/>
<value value-date="2017-01-01">20</value>
</transaction>
<transaction>
<transaction-type code="2"/>
<transaction-date iso-date="2017-01-01"/>
<value value-date="2017-01-01">30</value>
</transaction>
<transaction>
<transaction-type code="3"/>
<transaction-date iso-date="2017-01-01"/>
<value value-date="2017-01-01">40</value>
</transaction>
</iati-activity>
</iati-activities>
38 changes: 19 additions & 19 deletions cove_iati/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,10 @@ def test_cove_iati_cli_openag_output():
'message': 'the activity should include at least one location element',
'path': '/iati-activities/iati-activity[1]',
'rule': 'element is expected'},
{'id': 'AA-AAA-123123-AA123',
'message': 'openag:tag element must have @vocabulary attribute',
'path': '/iati-activities/iati-activity[1]/openag:tag',
'rule': 'element must have @vocabulary attribute with code for "maintained by the reporting organisation"'},
{'id': 'AA-AAA-123123-AA123',
'message': '@ref NO-ORGIDS-10000 does not start with a recognised org-ids prefix',
'path': '/iati-activities/iati-activity[1]/reporting-org/@ref',
Expand All @@ -223,14 +227,6 @@ def test_cove_iati_cli_openag_output():
'message': 'location/location-id element must have @code attribute',
'path': '/iati-activities/iati-activity[2]/location/location-id',
'rule': 'element must use @code attribute'},
{'id': 'BB-BBB-123123-BB123',
'message': 'location/location-id element must have @vocabulary attribute',
'path': '/iati-activities/iati-activity[2]/location/location-id',
'rule': 'element must use @vocabulary attribute'},
{'id': 'BB-BBB-123123-BB123',
'message': '"90" is not a valid value for @vocabulary attribute (it should be "98 or 99")',
'path': '/iati-activities/iati-activity[2]/openag:tag/@vocabulary',
'rule': 'element must have @vocabulary attribute with code for "maintained by the reporting organisation"'},
{'id': 'BB-BBB-123123-BB123',
'message': '"http://bad.org" is not a valid value for @vocabulary-uri attribute (it should be "http://aims.fao.org/aos/agrovoc/")',
'path': '/iati-activities/iati-activity[2]/openag:tag/@vocabulary-uri',
Expand All @@ -240,21 +236,25 @@ def test_cove_iati_cli_openag_output():
'path': '/iati-activities/iati-activity[2]/participating-org/@ref',
'rule': '@ref should have an org-ids prefix'},
{'id': 'CC-CCC-789789-CC789',
'message': 'openag:tag element must have @code attribute',
'path': '/iati-activities/iati-activity[3]/openag:tag',
'rule': 'element must have @code attribute'},
{'id': 'CC-CCC-789789-CC789',
'message': 'openag:tag element must have @vocabulary-uri attribute',
'path': '/iati-activities/iati-activity[3]/openag:tag',
'rule': 'element must have @vocabulary-uri attribute with agrovoc uri'},
'message': 'location/location-id element must have @vocabulary attribute',
'path': '/iati-activities/iati-activity[3]/location/location-id',
'rule': 'element must use @vocabulary attribute'},
{'id': 'CC-CCC-789789-CC789',
'message': 'openag:tag element must have @vocabulary attribute',
'path': '/iati-activities/iati-activity[3]/openag:tag',
'message': '"01" is not a valid value for @vocabulary attribute (it should be "98 or 99")',
'path': '/iati-activities/iati-activity[3]/openag:tag/@vocabulary',
'rule': 'element must have @vocabulary attribute with code for "maintained by the reporting organisation"'},
{'id': 'DD-DDD-789789-DD789',
'message': 'openag:tag element must have @code attribute',
'path': '/iati-activities/iati-activity[4]/openag:tag',
'rule': 'element must have @code attribute'},
{'id': 'EE-DDD-789789-EE789',
'message': 'the activity should include at least one openag:tag element',
'path': '/iati-activities/iati-activity[4]',
'rule': 'element is expected'}]
'path': '/iati-activities/iati-activity[5]',
'rule': 'element is expected'},
{'id': 'EE-DDD-789789-EE789',
'message': 'location must contain a location-id element',
'path': '/iati-activities/iati-activity[5]/location',
'rule': 'element must include <location-id>'}]

file_path = os.path.join('cove_iati', 'fixtures', 'iati_openag_tag.xml')
output_dir = os.path.join('media', str(uuid.uuid4()))
Expand Down

0 comments on commit 3b3e394

Please sign in to comment.