def test_get_btcusdt_when_loaded_returns_expected_instrument(self): # Arrange mock_client = MagicMock() mock_client.name = "Binance" with open(TEST_PATH + "res_instruments.json") as response: instruments = json.load(response) mock_client.markets = instruments provider = BinanceInstrumentProvider(client=mock_client) provider.load_all() symbol = Symbol("BTC/USDT", Venue("BINANCE")) # Act instrument = provider.get(symbol) # Assert self.assertEqual(Instrument, type(instrument)) self.assertEqual(AssetClass.CRYPTO, instrument.asset_class) self.assertEqual(AssetType.SPOT, instrument.asset_type) self.assertEqual(BTC, instrument.base_currency) self.assertEqual(USDT, instrument.quote_currency) self.assertEqual(USDT, instrument.settlement_currency)
def test_get_btcusdt_when_not_loaded_returns_none(self): # Arrange mock_client = MagicMock() mock_client.name = "Binance" provider = BinanceInstrumentProvider(client=mock_client) symbol = Symbol("BTC/USDT", Venue("BINANCE")) # Act instrument = provider.get(symbol) # Assert self.assertIsNone(instrument)