-
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.
tests: Add more tests, and add TODO note with more tests needed for b…
…ad data
- Loading branch information
Showing
2 changed files
with
52 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,48 @@ | ||
# TODO When country, sector, etc specified on transaction directly, no splits should occur. Test that here | ||
from iati_activity_details_split_by_fields.iati_activity import IATIActivity | ||
from iati_activity_details_split_by_fields.iati_activity_transaction import ( | ||
IATIActivityTransaction, | ||
) | ||
from iati_activity_details_split_by_fields.iati_activity_transaction_sector import ( | ||
IATIActivityTransactionSector, | ||
) | ||
|
||
|
||
def test_country_set(): | ||
|
||
iati_activity = IATIActivity( | ||
transactions=[IATIActivityTransaction(value=1000, recipient_country_code="GB")], | ||
) | ||
|
||
results = iati_activity.get_transactions_split_as_json() | ||
|
||
assert [ | ||
{ | ||
"recipient_country_code": "GB", | ||
"sectors": [], | ||
"value": 1000, | ||
} | ||
] == results | ||
|
||
|
||
def test_sector_set(): | ||
|
||
iati_activity = IATIActivity( | ||
transactions=[ | ||
IATIActivityTransaction( | ||
value=1000, | ||
sectors=[ | ||
IATIActivityTransactionSector(vocabulary="cats", code="Henry") | ||
], | ||
) | ||
], | ||
) | ||
|
||
results = iati_activity.get_transactions_split_as_json() | ||
|
||
assert [ | ||
{ | ||
"recipient_country_code": None, | ||
"sectors": [{"code": "Henry", "vocabulary": "cats"}], | ||
"value": 1000, | ||
}, | ||
] == results |
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,4 @@ | ||
# TODO | ||
# What happens when a country, region, sector is set at BOTH Activity and Transaction? | ||
# According to standard, this isn't allowed! | ||
# But we should test this to make sure bad data is ok |