-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from pwyf/fix-commitment
test defns: Fix commitment test to not always fail
- Loading branch information
Showing
3 changed files
with
115 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
from os.path import dirname, join, realpath | ||
from unittest import TestCase | ||
|
||
from bdd_tester import BDDTester | ||
from lxml import etree | ||
|
||
|
||
class TestCommitments(TestCase): | ||
def setUp(self): | ||
self.FILEPATH = dirname(realpath(__file__)) | ||
steps_path = join(self.FILEPATH, '..', '..', 'test_definitions', | ||
'step_definitions.py') | ||
feature_path = join(self.FILEPATH, '..', '..', 'test_definitions', | ||
'finance', | ||
'11_commitment.feature') | ||
|
||
tester = BDDTester(steps_path) | ||
feature = tester.load_feature(feature_path) | ||
self.test = feature.tests[0] | ||
|
||
def test_commitment_no_value(self): | ||
xml = ''' | ||
<iati-activity> | ||
<activity-status code="2"/> | ||
<transaction> | ||
<transaction-type code="2"/> | ||
</transaction> | ||
</iati-activity> | ||
''' | ||
|
||
activity = etree.fromstring(xml) | ||
result = self.test(activity) | ||
|
||
assert result is False | ||
|
||
def test_commitment_zero_value(self): | ||
xml = ''' | ||
<iati-activity> | ||
<activity-status code="2"/> | ||
<transaction> | ||
<transaction-type code="2"/> | ||
<value>0</value> | ||
</transaction> | ||
</iati-activity> | ||
''' | ||
|
||
activity = etree.fromstring(xml) | ||
result = self.test(activity) | ||
|
||
assert result is False | ||
|
||
def test_commitment_zero_value_decimal(self): | ||
xml = ''' | ||
<iati-activity> | ||
<activity-status code="2"/> | ||
<transaction> | ||
<transaction-type code="2"/> | ||
<value>0.0</value> | ||
</transaction> | ||
</iati-activity> | ||
''' | ||
|
||
activity = etree.fromstring(xml) | ||
result = self.test(activity) | ||
|
||
assert result is False | ||
|
||
def test_commitment_non_zero(self): | ||
xml = ''' | ||
<iati-activity> | ||
<activity-status code="2"/> | ||
<transaction> | ||
<transaction-type code="2"/> | ||
<value>123.45</value> | ||
</transaction> | ||
</iati-activity> | ||
''' | ||
|
||
activity = etree.fromstring(xml) | ||
result = self.test(activity) | ||
|
||
assert result is True | ||
|
||
def test_commitment_not_present(self): | ||
xml = ''' | ||
<iati-activity> | ||
<activity-status code="2"/> | ||
<transaction> | ||
<transaction-type code="3"/> | ||
</transaction> | ||
</iati-activity> | ||
''' | ||
|
||
activity = etree.fromstring(xml) | ||
result = self.test(activity) | ||
|
||
assert result is False | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters