def test_get_snapshot_raises_on_status_code(self, mock_api): url = f"{CONSTANTS.REST_URL}{CONSTANTS.PRODUCTS_PATH_URL}/{self.trading_pair}/book?level=3" resp = self.get_products_book_response_mock() mock_api.get(url, body=json.dumps(resp), status=401) rest_assistant = self.ev_loop.run_until_complete( build_coinbase_pro_web_assistant_factory().get_rest_assistant()) with self.assertRaises(IOError): self.async_run_with_timeout( coroutine=CoinbaseProAPIOrderBookDataSource.get_snapshot( rest_assistant, self.trading_pair))
def test_get_snapshot(self, mock_api): url = f"{CONSTANTS.REST_URL}{CONSTANTS.PRODUCTS_PATH_URL}/{self.trading_pair}/book?level=3" resp = self.get_products_book_response_mock() mock_api.get(url, body=json.dumps(resp)) rest_assistant = self.ev_loop.run_until_complete( build_coinbase_pro_web_assistant_factory().get_rest_assistant()) ret = self.async_run_with_timeout( coroutine=CoinbaseProAPIOrderBookDataSource.get_snapshot( rest_assistant, self.trading_pair)) self.assertEqual(resp, ret) # shallow comparison ok