Skip to content

Commit dae95d3

Browse files
authored
add cardReversalTransaction to codecs (unit-finance#111)
* new test: compare TransactionDTO's in mappings to TransactionDTO's in model. * update test * small change to test
1 parent abe5cda commit dae95d3

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

e2e_tests/transaction_test.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import os
2-
import unittest
32
from unit import Unit
43
from unit.models.transaction import *
5-
from unit.models.codecs import DtoDecoder
4+
from unit.models.codecs import DtoDecoder, mappings
65

76
token = os.environ.get('TOKEN')
87
client = Unit("https://api.s.unit.sh", token)
@@ -548,3 +547,23 @@ def test_list_and_get_transactions_with_type():
548547
response = client.transactions.get(id)
549548
assert response.data.type == "receivedAchTransaction" or response.data.type == "feeTransaction"
550549

550+
551+
def test_codecs_transactions():
552+
import inspect
553+
import unit.models.transaction as umt
554+
555+
classes = []
556+
557+
558+
for name, obj in inspect.getmembers(umt):
559+
try:
560+
if 'TransactionDTO' in name and 'Base' not in name and name != 'TransactionDTO':
561+
classes.append(name.replace('DTO', ''))
562+
except Exception as e:
563+
print(e)
564+
continue
565+
566+
567+
transactions = [x for x in mappings if "Transaction" in x]
568+
569+
assert len(transactions) == len(classes)

unit/models/codecs.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@
125125
"chargebackTransaction": lambda _id, _type, attributes, relationships:
126126
ChargebackTransactionDTO.from_json_api(_id, _type, attributes, relationships),
127127

128+
"cardReversalTransaction": lambda _id, _type, attributes, relationships:
129+
CardReversalTransactionDTO.from_json_api(_id, _type, attributes, relationships),
130+
128131
"achPayment": lambda _id, _type, attributes, relationships:
129132
AchPaymentDTO.from_json_api(_id, _type, attributes, relationships),
130133

0 commit comments

Comments
 (0)