Skip to content

Commit

Permalink
Merge pull request #149 from IATI/validate-budget-not-provided
Browse files Browse the repository at this point in the history
Split comprehensiveness budget and budget-not-provided
  • Loading branch information
samuele-mattiuzzo committed Mar 14, 2019
2 parents 5ad867e + 2eec4d8 commit e6bffcb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion get_stats.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -e

mkdir gitout
for f in ckan gitdate; do
curl --compressed "http://dashboard.iatistandard.org/stats/${f}.json" > gitout/${f}.json
curl --compress "http://dashboard.iatistandard.org/stats/${f}.json" > gitout/${f}.json
done

mkdir stats-blacklist
Expand Down
22 changes: 11 additions & 11 deletions stats/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -1033,9 +1033,8 @@ def is_text_in_element(elementName):
'transaction_currency': all_true_and_not_empty(x.xpath('value/@value-date') and x.xpath('../@default-currency|./value/@currency') for x in self.element.findall('transaction')),
'transaction_traceability': all_true_and_not_empty(x.xpath('provider-org/@provider-activity-id') for x in self.element.xpath('transaction[transaction-type/@code="{}"]'.format(self._incoming_funds_code()))) or
self._is_donor_publisher(),
'budget': (
self.element.findall('budget') or
self._budget_not_provided() is not None),
'budget': self.element.findall('budget'),
'budget_not_provided': self._budget_not_provided() is not None,
'contact-info': self.element.findall('contact-info/email'),
'location': self.element.xpath('location/point/pos|location/name|location/description|location/location-administrative'),
'location_point_pos': self.element.xpath('location/point/pos'),
Expand Down Expand Up @@ -1139,14 +1138,15 @@ def empty_or_percentage_sum_is_100(path, by_vocab=False):
),
'budget': (
bools['budget'] and
(all(
valid_date(budget.find('period-start')) and
valid_date(budget.find('period-end')) and
valid_date(budget.find('value')) and
valid_value(budget.find('value'))
for budget in bools['budget']) or
((len(self.element.findall('budget')) == 0) and
self._budget_not_provided() is not None))),
all(
valid_date(budget.find('period-start')) and
valid_date(budget.find('period-end')) and
valid_date(budget.find('value')) and
valid_value(budget.find('value'))
for budget in bools['budget'])),
'budget_not_provided': (
bools['budget_not_provided'] and
str(self._budget_not_provided()) in CODELISTS[self._major_version()]['BudgetNotProvided']),
'location_point_pos': all_true_and_not_empty(
valid_coords(x.text) for x in bools['location_point_pos']),
'sector_dac': (
Expand Down
6 changes: 6 additions & 0 deletions stats/tests/test_comprehensiveness.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ def test_comprehensiveness_empty(major_version):
'transaction_currency': 0,
'transaction_traceability': 0,
'budget': 0,
'budget_not_provided': 0,
'contact-info': 0,
'location': 0,
'location_point_pos': 0,
Expand Down Expand Up @@ -319,6 +320,7 @@ def test_comprehensiveness_full(major_version):
'transaction_currency': 1,
'transaction_traceability': 1,
'budget': 1,
'budget_not_provided': 0,
'contact-info': 1,
'location': 1,
'location_point_pos': 1,
Expand Down Expand Up @@ -393,6 +395,7 @@ def test_comprehensiveness_other_passes(major_version):
'transaction_currency': 1,
'transaction_traceability': 0,
'budget': 0,
'budget_not_provided': 0,
'contact-info': 0,
'location': 0,
'location_point_pos': 0,
Expand Down Expand Up @@ -1514,6 +1517,7 @@ def test_comprehensiveness_dac_sector_codes_v2(major_version):
'transaction_currency': 1,
'transaction_traceability': 1,
'budget': 1,
'budget_not_provided': 0,
'contact-info': 1,
'location': 1,
'location_point_pos': 1,
Expand Down Expand Up @@ -1605,6 +1609,7 @@ def test_comprehensiveness_dac_sector_codes_v2_incomplete(major_version):
'transaction_currency': 1,
'transaction_traceability': 1,
'budget': 1,
'budget_not_provided': 0,
'contact-info': 1,
'location': 1,
'location_point_pos': 1,
Expand Down Expand Up @@ -1689,6 +1694,7 @@ def test_comprehensiveness_v1_returns_false(major_version):
'transaction_currency': 1,
'transaction_traceability': 1,
'budget': 1,
'budget_not_provided': 0,
'contact-info': 1,
'location': 1,
'location_point_pos': 1,
Expand Down

0 comments on commit e6bffcb

Please sign in to comment.