def test__set_current_node_with_empty_balances(self): """ Test :meth:`ArbitrageStrategy._set_current_node` Assert :attr:`ArbitrageStrategy.current_node` is unchanged. """ arbitrage = ArbitrageStrategy() UNCHANGED_NODE = 'FAKE' arbitrage.current_node = UNCHANGED_NODE TEST_CURRENCY = 'USD' TEST_2ND_CURRENCY = 'BTC' TEST_BALANCE = 0.0 arbitrage.accounts = [ { 'currency': TEST_CURRENCY, 'balance': TEST_BALANCE, }, { 'currency': TEST_2ND_CURRENCY, 'balance': TEST_BALANCE, } ] arbitrage.ticker = {} arbitrage._set_current_node() self.assertEqual(arbitrage.current_node, UNCHANGED_NODE)
def test__set_current_node_with_valid_balance(self): """ Test :meth:`ArbitrageStrategy._set_current_node` Assert :attr:`ArbitrageStrategy.current_node` is set to the first account currency with a positive balance. """ arbitrage = ArbitrageStrategy() UNCHANGED_NODE = 'FAKE' arbitrage.current_node = UNCHANGED_NODE TEST_CURRENCY = 'USD' TEST_2ND_CURRENCY = 'BTC' TEST_BALANCE = 1.0 arbitrage.accounts = [ { 'currency': TEST_CURRENCY, 'balance': TEST_BALANCE, }, { 'currency': TEST_2ND_CURRENCY, 'balance': TEST_BALANCE, } ] arbitrage.ticker = {} arbitrage._set_current_node() self.assertEqual(arbitrage.current_node, TEST_CURRENCY)
def test__set_current_node_with_invalid_account_data(self): """ Test :meth:`ArbitrageStrategy._set_current_node` Assert :attr:`ArbitrageStrategy.current_node` is unchanged. """ arbitrage = ArbitrageStrategy() UNCHANGED_NODE = 'FAKE' arbitrage.current_node = UNCHANGED_NODE TEST_CURRENCY = 'USD' TEST_BALANCE = 1.0 arbitrage.accounts = [ { 'error': 'Invalid account data.', } ] arbitrage.ticker = {} arbitrage._set_current_node() self.assertEqual(arbitrage.current_node, UNCHANGED_NODE)