Skip to content

Commit

Permalink
tests: Add more tests, and add TODO note with more tests needed for b…
Browse files Browse the repository at this point in the history
…ad data
  • Loading branch information
odscjames committed Nov 13, 2024
1 parent b0535d4 commit 42c4ecd
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
49 changes: 48 additions & 1 deletion tests/test_at_transaction_level.py
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
4 changes: 4 additions & 0 deletions tests/test_both_at_activity_and_transaction_level.py
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

0 comments on commit 42c4ecd

Please sign in to comment.