Skip to content

Commit

Permalink
[#59] Fix logic & tests for comprehensiveness demominators. Now in li…
Browse files Browse the repository at this point in the history
…ne with public methodology
  • Loading branch information
dalepotter committed Nov 5, 2015
1 parent 4b84d15 commit 2b19c47
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion stats/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ def comprehensiveness_denominators(self):
else:
start_date = None
return {
'transaction_spend': 1 if start_date and start_date < self.today and self.today - start_date < datetime.timedelta(days=365) else 0,
'transaction_spend': 1 if start_date and start_date < self.today and (self.today - start_date) > datetime.timedelta(days=365) else 0,
'transaction_traceability': 1 if self.element.xpath('transaction[transaction-type/@code="{}"]'.format(self._incoming_funds_code())) else 0,
}
else:
Expand Down
20 changes: 10 additions & 10 deletions stats/tests/test_comprehensiveness.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def test_comprehensiveness_full(major_version):
<title>A title</title>
<description>A description</description>
<activity-status code="2"/>
<activity-date type="start-actual" iso-date="9990-05-01" />
<activity-date type="start-actual" iso-date="9989-05-01" />
<sector vocabulary="DAC"/>
<recipient-country code="AI"/>
<transaction>
Expand Down Expand Up @@ -259,7 +259,7 @@ def test_comprehensiveness_full(major_version):
<narrative>A description</narrative>
</description>
<activity-status code="2"/>
<activity-date type="2" iso-date="9990-05-01" />
<activity-date type="2" iso-date="9989-05-01" />
<sector vocabulary="1"/>
<recipient-country code="AI"/>
<transaction>
Expand Down Expand Up @@ -348,7 +348,7 @@ def test_comprehensiveness_other_passes(major_version):
<iati-activity default-currency="">
<!-- default currency can be used instead of at transaction level -->
<activity-status code="2"/>
<activity-date type="start-planned" iso-date="9990-05-01" />
<activity-date type="start-planned" iso-date="9989-05-01" />
<transaction>
<transaction-type code="D"/>
<value value-date="2014-01-01"/>
Expand All @@ -360,7 +360,7 @@ def test_comprehensiveness_other_passes(major_version):
<iati-activity default-currency="">
<!-- default currency can be used instead of at transaction level -->
<activity-status code="2"/>
<activity-date type="1" iso-date="9990-05-01" />
<activity-date type="1" iso-date="9989-05-01" />
<transaction>
<transaction-type code="3"/><!-- Disbursement -->
<value value-date="2014-01-01"/>
Expand Down Expand Up @@ -693,7 +693,7 @@ def test_comprehensiveness_with_validation_transaction_spend(major_version):
<iati-activities>
<iati-activity>
<activity-status code="2"/>
<activity-date type="start-planned" iso-date="9990-05-01" />
<activity-date type="start-planned" iso-date="9989-05-01" />
<transaction>
<transaction-type code="D"/>
<value value-date="" currency=""/>
Expand All @@ -704,7 +704,7 @@ def test_comprehensiveness_with_validation_transaction_spend(major_version):
<iati-activities>
<iati-activity>
<activity-status code="2"/>
<activity-date type="1" iso-date="9990-05-01" />
<activity-date type="1" iso-date="9989-05-01" />
<transaction>
<transaction-type code="3"/>
<value value-date="" currency=""/>
Expand All @@ -719,7 +719,7 @@ def test_comprehensiveness_with_validation_transaction_spend(major_version):
<iati-activities>
<iati-activity>
<activity-status code="2"/>
<activity-date type="start-planned" iso-date="9990-05-01" />
<activity-date type="start-planned" iso-date="9989-05-01" />
<transaction>
<transaction-type code="D"/>
<value value-date="2014-01-01" currency="GBP">1.0</value>
Expand All @@ -731,7 +731,7 @@ def test_comprehensiveness_with_validation_transaction_spend(major_version):
<iati-activities>
<iati-activity>
<activity-status code="2"/>
<activity-date type="1" iso-date="9990-05-01" />
<activity-date type="1" iso-date="9989-05-01" />
<transaction>
<transaction-type code="3"/>
<value value-date="2014-01-01" currency="GBP">1.0</value>
Expand Down Expand Up @@ -1010,7 +1010,7 @@ def test_transaction_non_exclusions(key, major_version):
activity_stats.element = etree.fromstring('''
<iati-activity>
<activity-status code="2"/>
<activity-date type="start-planned" iso-date="9990-01-01" />
<activity-date type="start-planned" iso-date="9989-01-01" />
<transaction>
<transaction-type code="IF"/>
</transaction>
Expand All @@ -1021,7 +1021,7 @@ def test_transaction_non_exclusions(key, major_version):
''' if major_version == '1' else '''
<iati-activity>
<activity-status code="2"/>
<activity-date type="1" iso-date="9990-01-01" />
<activity-date type="1" iso-date="9989-01-01" />
<transaction>
<transaction-type code="1"/>
</transaction>
Expand Down

0 comments on commit 2b19c47

Please sign in to comment.