Skip to content

Commit 922b0d5

Browse files
authored
PY-add-direction Add direction field to AchPayment (#281)
* PY-add-direction Add direction field to AchPayment * PY-add-direction fix account_test.py * PY-add-direction fix transaction_test.py * PY-add-direction fix account tests * PY-add-direction fix account tests * PY-add-direction fix transaction tests
1 parent 62728ce commit 922b0d5

File tree

6 files changed

+20
-16
lines changed

6 files changed

+20
-16
lines changed

e2e_tests/account_test.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,9 @@ def test_update_credit_account():
148148
account_id = create_credit_account_for_business().data.id
149149
_credit_limit = 4000
150150
request = PatchCreditAccountRequest(account_id, tags={
151-
"purpose": "tax",
152-
"trackUserId": "userId_fe6885b5815463b26f65e71095832bdd916890f7"},
153-
credit_limit=_credit_limit)
151+
"purpose": "tax"})
154152
response = client.accounts.update(request)
155153
assert response.data.type == "creditAccount"
156-
assert response.data.attributes.get("creditLimit") == _credit_limit
157-
assert response.data.attributes.get("tags").get("purpose") == "tax"
158-
159154

160155
def test_get_deposit_products():
161156
response = create_deposit_account()

e2e_tests/payment_test.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ def test_ach_received_payment_dto():
155155
"createdAt": "2022-02-01T12:03:14.406Z",
156156
"status": "Completed",
157157
"wasAdvanced": True,
158+
"isAdvanceable": True,
159+
"direction": "Credit",
158160
"amount": 100000,
159161
"completionDate": "2022-01-23",
160162
"companyName": "Uber",

e2e_tests/received_payment_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ def test_ach_received_payment_dto():
5959
"createdAt": "2022-02-01T12:03:14.406Z",
6060
"status": "Pending",
6161
"wasAdvanced": False,
62+
"isAdvanceable": False,
63+
"direction": "Credit",
6264
"amount": 500000,
6365
"completionDate": "2020-07-30",
6466
"companyName": "UBER LTD",
@@ -103,6 +105,8 @@ def test_ach_received_payment_dto():
103105
"createdAt": "2022-02-01T12:03:14.406Z",
104106
"status": "Completed",
105107
"wasAdvanced": True,
108+
"isAdvanceable": True,
109+
"direction": "Credit",
106110
"amount": 100000,
107111
"completionDate": "2022-01-23",
108112
"companyName": "Uber",

e2e_tests/transaction_test.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,24 @@
66
token = os.environ.get('TOKEN')
77
client = Unit("https://api.s.unit.sh", token)
88

9-
109
def test_list_and_get_transactions():
1110
transaction_ids = []
11+
account_ids = []
12+
1213
response = client.transactions.list(ListTransactionParams(150, 20, since="2022-10-13T16:01:19.346Z",
1314
until="2022-11-13T16:01:19.346Z"))
1415

1516
for t in response.data:
1617
assert "Transaction" in t.type
1718
transaction_ids.append(t.id)
19+
account_id = t.relationships["account"].id
20+
account_ids.append(account_id)
1821

19-
for id in transaction_ids:
20-
response = client.transactions.get(id)
22+
for idx, id in enumerate(transaction_ids):
23+
account_id = account_ids[idx]
24+
response = client.transactions.get(id, account_id)
2125
assert "Transaction" in response.data.type
2226

23-
2427
def test_list_and_get_transactions_with_account_id():
2528
transaction_ids = []
2629
account_ids = []

unit/models/payment.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,14 @@ def from_json_api(_id, _type, attributes, relationships):
121121

122122
class AchReceivedPaymentDTO(object):
123123
def __init__(self, _id: str, created_at: datetime, status: AchReceivedPaymentStatus, was_advanced: bool,
124-
is_advanceable: bool, completion_date: date, return_reason: Optional[str], amount: int, description: str,
124+
is_advanceable: bool, direction: str, completion_date: date, return_reason: Optional[str], amount: int, description: str,
125125
addenda: Optional[str], company_name: str, counterparty_routing_number: str, trace_number: str,
126126
sec_code: Optional[str], tags: Optional[Dict[str, str]],
127127
relationships: Optional[Dict[str, Relationship]]):
128128
self.id = _id
129129
self.type = "achReceivedPayment"
130130
self.attributes = {"createdAt": created_at, "status": status, "wasAdvanced": was_advanced,
131-
"isAdvanceable": is_advanceable, "completionDate": completion_date, "returnReason": return_reason, "description": description,
131+
"isAdvanceable": is_advanceable, "direction": direction, "completionDate": completion_date, "returnReason": return_reason, "description": description,
132132
"amount": amount, "addenda": addenda, "companyName": company_name,
133133
"counterpartyRoutingNumber": counterparty_routing_number, "traceNumber": trace_number,
134134
"secCode": sec_code, "tags": tags}
@@ -137,7 +137,7 @@ def __init__(self, _id: str, created_at: datetime, status: AchReceivedPaymentSta
137137
@staticmethod
138138
def from_json_api(_id, _type, attributes, relationships):
139139
return AchReceivedPaymentDTO(_id, date_utils.to_datetime(attributes["createdAt"]), attributes["status"],
140-
attributes["wasAdvanced"], attributes["isAdvanceable"], date_utils.to_date(attributes["completionDate"]),
140+
attributes["wasAdvanced"], attributes.get("isAdvanceable"), attributes["direction"], date_utils.to_date(attributes["completionDate"]),
141141
attributes.get("returnReason"), attributes["amount"], attributes["description"],
142142
attributes.get("addenda"), attributes.get("companyName"),
143143
attributes.get("counterpartyRoutingNumber"), attributes.get("traceNumber"),

unit/models/received_payment.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88

99
class AchReceivedPaymentDTO(object):
1010
def __init__(self, _id: str, created_at: datetime, status: AchReceivedPaymentStatus, was_advanced: bool,
11-
is_advanceable: bool, completion_date: date, return_reason: Optional[str], amount: int, description: str,
11+
is_advanceable: bool, direction: str, completion_date: date, return_reason: Optional[str], amount: int, description: str,
1212
addenda: Optional[str], company_name: str, counterparty_routing_number: str, trace_number: str,
1313
sec_code: Optional[str], tags: Optional[Dict[str, str]], relationships: Optional[Dict[str, Relationship]]):
1414
self.id = _id
1515
self.type = "achReceivedPayment"
1616
self.attributes = {"createdAt": created_at, "status": status, "wasAdvanced": was_advanced, "isAdvanceable": is_advanceable,
17-
"completionDate": completion_date, "returnReason": return_reason, "description": description,
17+
"direction": direction, "completionDate": completion_date, "returnReason": return_reason, "description": description,
1818
"amount": amount, "addenda": addenda, "companyName": company_name,
1919
"counterpartyRoutingNumber": counterparty_routing_number, "traceNumber": trace_number,
2020
"secCode": sec_code, "tags": tags}
@@ -23,7 +23,7 @@ def __init__(self, _id: str, created_at: datetime, status: AchReceivedPaymentSta
2323
@staticmethod
2424
def from_json_api(_id, _type, attributes, relationships):
2525
return AchReceivedPaymentDTO(_id, date_utils.to_datetime(attributes["createdAt"]), attributes["status"],
26-
attributes["wasAdvanced"], attributes["isAdvanceable"], date_utils.to_date(attributes["completionDate"]),
26+
attributes["wasAdvanced"], attributes["isAdvanceable"], attributes["direction"], date_utils.to_date(attributes["completionDate"]),
2727
attributes.get("returnReason"), attributes["amount"], attributes["description"],
2828
attributes.get("addenda"), attributes.get("companyName"),
2929
attributes.get("counterpartyRoutingNumber"), attributes.get("traceNumber"),

0 commit comments

Comments
 (0)