Add tests for fee extraction methods
This commit is contained in:
parent
2e4dc6c253
commit
e74ed0ba7b
@ -1087,6 +1087,8 @@ class Exchange:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def extract_cost_curr_rate(order: Dict) -> Tuple[float, str, float]:
|
def extract_cost_curr_rate(order: Dict) -> Tuple[float, str, float]:
|
||||||
"""
|
"""
|
||||||
|
Extract tuple of cost, currency, rate.
|
||||||
|
Requires order_has_fee to run first!
|
||||||
:param order: Order or trade (one trade) dict
|
:param order: Order or trade (one trade) dict
|
||||||
:return: Tuple with cost, currency, rate of the given fee dict
|
:return: Tuple with cost, currency, rate of the given fee dict
|
||||||
"""
|
"""
|
||||||
|
@ -2145,3 +2145,23 @@ def test_symbol_is_pair(market_symbol, base_currency, quote_currency, expected_r
|
|||||||
])
|
])
|
||||||
def test_market_is_active(market, expected_result) -> None:
|
def test_market_is_active(market, expected_result) -> None:
|
||||||
assert market_is_active(market) == expected_result
|
assert market_is_active(market) == expected_result
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("order,expected", [
|
||||||
|
([{'fee'}], False),
|
||||||
|
({'fee': None}, False),
|
||||||
|
({'fee': {'currency': 'ETH/BTC'}}, False),
|
||||||
|
({'fee': {'currency': 'ETH/BTC', 'cost': None}}, False),
|
||||||
|
({'fee': {'currency': 'ETH/BTC', 'cost': 0.01}}, True),
|
||||||
|
])
|
||||||
|
def test_order_has_fee(order, expected) -> None:
|
||||||
|
assert Exchange.order_has_fee(order) == expected
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("order,expected", [
|
||||||
|
({'fee': {'currency': 'ETH/BTC', 'cost': 0.43}}, (0.43, 'ETH/BTC', None)),
|
||||||
|
({'fee': {'currency': 'ETH/USDT', 'cost': 0.01}}, (0.01, 'ETH/USDT', None)),
|
||||||
|
({'fee': {'currency': 'ETH/USDT', 'cost': 0.34, 'rate': 0.01}}, (0.34, 'ETH/USDT', 0.01)),
|
||||||
|
])
|
||||||
|
def test_extract_cost_curr_rate(order, expected) -> None:
|
||||||
|
assert Exchange.extract_cost_curr_rate(order) == expected
|
||||||
|
Loading…
Reference in New Issue
Block a user