def test_get_btc_currency_when_not_loaded_returns_none(self): # Arrange mock_client = MagicMock() mock_client.name = "Binance" mock_client.precisionMode = 2 provider = CCXTInstrumentProvider(client=mock_client) provider.load_all() # Act currency = provider.currency("BTC") # Assert self.assertIsNone(currency)
def test_get_btc_currency_when_loaded_returns_expected_currency(self): # Arrange with open(TEST_PATH + "markets.json") as response: markets = json.load(response) with open(TEST_PATH + "currencies.json") as response: currencies = json.load(response) mock_client = MagicMock() mock_client.name = "Binance" mock_client.precisionMode = 2 mock_client.markets = markets mock_client.currencies = currencies provider = CCXTInstrumentProvider(client=mock_client) provider.load_all() # Act currency = provider.currency("BTC") # Assert self.assertEqual(Currency, type(currency)) self.assertEqual("BTC", currency.code) self.assertEqual(8, currency.precision)