Refactor transactions into readable code
This commit is contained in:
@@ -45,6 +45,7 @@ class TestTransactions(TestCase):
|
||||
|
||||
# Mock the rates
|
||||
self.transactions.money = MagicMock()
|
||||
self.transactions.money.to_usd = self.mock_to_usd
|
||||
self.transactions.money.get_rates_all = MagicMock()
|
||||
self.transactions.money.get_rates_all.return_value = {"GBP": 0.8}
|
||||
|
||||
@@ -119,6 +120,17 @@ class TestTransactions(TestCase):
|
||||
if trade["id"] == string:
|
||||
return trade["reference"]
|
||||
|
||||
def mock_to_usd(self, amount, currency):
|
||||
if currency == "GBP":
|
||||
return amount * 1.3
|
||||
elif currency == "USD":
|
||||
return amount
|
||||
# fuck it who cares
|
||||
elif currency == "SEK":
|
||||
return 100
|
||||
elif currency == "EUR":
|
||||
return 10
|
||||
|
||||
def test_transaction(self):
|
||||
self.transactions.transaction(self.test_data)
|
||||
self.transactions.release_funds.assert_called_once_with("uuid1", "TEST-1")
|
||||
@@ -154,7 +166,7 @@ class TestTransactions(TestCase):
|
||||
|
||||
def test_transaction_no_reference_pass(self):
|
||||
no_reference_pass = self.data_custom(1, "GBP", "none")
|
||||
no_reference_pass["meta"]["provider_reference"] = "none"
|
||||
no_reference_pass["meta"]["provider_reference"] = "THIS_ONE_FAILS"
|
||||
self.return_trades = [1]
|
||||
|
||||
self.transactions.transaction(no_reference_pass)
|
||||
|
||||
Reference in New Issue
Block a user