Fix transactions tests
This commit is contained in:
parent
fbe9dc2325
commit
c213fe9d5d
|
@ -10,28 +10,21 @@ class TestTransactions(TestCase):
|
|||
def setUp(self):
|
||||
self.transactions = transactions.Transactions()
|
||||
self.test_data = {
|
||||
"event": "TransactionCreated",
|
||||
"timestamp": "2022-02-24T20:26:15.232342Z",
|
||||
"data": {
|
||||
"id": "6217e9e7-43e1-a809-8500-0a5b0170e6e4",
|
||||
"type": "transfer",
|
||||
"state": "completed",
|
||||
"request_id": "8a15213e-a7d2-4738-bfb5-b1d037b75a57",
|
||||
"created_at": "2022-02-24T20:26:15.238218Z",
|
||||
"updated_at": "2022-02-24T20:26:15.238218Z",
|
||||
"completed_at": "2022-02-24T20:26:15.238453Z",
|
||||
"reference": "TEST-1",
|
||||
"legs": [
|
||||
{
|
||||
"leg_id": "80b35daf-409c-41be-8755-15982b7633a6",
|
||||
"account_id": "7185593b-d9ad-4456-920e-d9db109a5172",
|
||||
"counterparty": {"account_type": "revolut"},
|
||||
"amount": 1,
|
||||
"currency": "GBP",
|
||||
"description": "From Mark Veidemanis",
|
||||
"balance": 3832.3,
|
||||
}
|
||||
],
|
||||
"timestamp": "2022-03-14T19:34:13.501Z",
|
||||
"description": "Received Rebiere Matthieu",
|
||||
"transaction_type": "CREDIT",
|
||||
"transaction_category": "CREDIT",
|
||||
"transaction_classification": [],
|
||||
"amount": 1,
|
||||
"currency": "GBP",
|
||||
"transaction_id": "ec4df5248c750c30301a1da71024ac0b",
|
||||
"provider_transaction_id": "27373011.TU9ORVRBUllfQUNUSVZJVFk6OjI1MDE4MDQyOjpUUkFOU0ZFUjo6MzgwMDM2NDY2",
|
||||
"normalised_provider_transaction_id": "txn-c8c12c308789bd980",
|
||||
"meta": {
|
||||
"provider_reference": "TEST-1",
|
||||
"transaction_type": "Credit",
|
||||
"provider_id": "27373011.TU9ORVRBUllfQUNUSVZJVFk6OjI1MDE4MDQyOjpUUkFOU0ZFUjo6MzgwMDM2NDY2",
|
||||
"counter_party_preferred_name": "Rebiere Matthieu",
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -103,9 +96,9 @@ class TestTransactions(TestCase):
|
|||
|
||||
def data_custom(self, amount, currency, reference):
|
||||
test_data = self.test_data_copy
|
||||
test_data["data"]["reference"] = reference
|
||||
test_data["data"]["legs"][0]["amount"] = amount
|
||||
test_data["data"]["legs"][0]["currency"] = currency
|
||||
test_data["meta"]["provider_reference"] = reference
|
||||
test_data["amount"] = amount
|
||||
test_data["currency"] = currency
|
||||
return test_data
|
||||
|
||||
def mock_hgetall(self, string):
|
||||
|
@ -131,7 +124,7 @@ class TestTransactions(TestCase):
|
|||
|
||||
self.transactions.release_funds = MagicMock()
|
||||
ref_2 = self.test_data_copy
|
||||
ref_2["data"]["reference"] = "TEST-2"
|
||||
ref_2["meta"]["provider_reference"] = "TEST-2"
|
||||
self.transactions.transaction(ref_2)
|
||||
self.transactions.release_funds.assert_called_once_with("uuid2", "TEST-2")
|
||||
|
||||
|
@ -143,24 +136,24 @@ class TestTransactions(TestCase):
|
|||
|
||||
def test_transaction_malformed(self):
|
||||
malformed_data = self.test_data_copy
|
||||
del malformed_data["data"]
|
||||
del malformed_data["amount"]
|
||||
self.transactions.transaction(malformed_data)
|
||||
self.transactions.release_funds.assert_not_called()
|
||||
|
||||
malformed_data = self.test_data_copy
|
||||
del malformed_data["data"]["type"]
|
||||
del malformed_data["currency"]
|
||||
self.transactions.transaction(malformed_data)
|
||||
self.transactions.release_funds.assert_not_called()
|
||||
|
||||
def test_transaction_no_reference_fail(self):
|
||||
no_reference_fail = self.data_custom(1, "GBP", "none")
|
||||
no_reference_fail["data"]["reference"] = "none"
|
||||
no_reference_fail["meta"]["provider_reference"] = "none"
|
||||
self.transactions.transaction(no_reference_fail)
|
||||
self.transactions.release_funds.assert_not_called()
|
||||
|
||||
def test_transaction_no_reference_pass(self):
|
||||
no_reference_pass = self.data_custom(1, "GBP", "none")
|
||||
no_reference_pass["data"]["reference"] = "none"
|
||||
no_reference_pass["meta"]["provider_reference"] = "none"
|
||||
self.return_trades = [1]
|
||||
|
||||
self.transactions.transaction(no_reference_pass)
|
||||
|
@ -196,11 +189,11 @@ class TestTransactions(TestCase):
|
|||
self.transactions.transaction(wrong_amount)
|
||||
self.transactions.release_funds.assert_not_called()
|
||||
|
||||
def test_transaction_pending(self):
|
||||
pending_tx = self.test_data_copy
|
||||
pending_tx["data"]["state"] = "pending"
|
||||
self.transactions.transaction(pending_tx)
|
||||
self.transactions.release_funds.assert_not_called()
|
||||
# def test_transaction_pending(self):
|
||||
# pending_tx = self.test_data_copy
|
||||
# pending_tx["data"]["state"] = "pending"
|
||||
# self.transactions.transaction(pending_tx)
|
||||
# self.transactions.release_funds.assert_not_called()
|
||||
|
||||
def test_transaction_too_low(self):
|
||||
too_low = self.data_custom(5, "GBP", "TEST-1")
|
||||
|
|
Loading…
Reference in New Issue