def test_get_recent_transactions(api: GatecoinAPI): """Test fetching recent transactions from REST API""" response = GatecoinAPI().get_recent_transactions('BTCUSD') assert (response is not None), 'Response did not deserialize properly' assert (response.response_status.message == 'OK' ), 'API response not successful' assert (len(response.transactions) > 0), 'Empty transactions list' for transaction in response.transactions: _test_transaction(transaction)
def api() -> GatecoinAPI: """Fixture to return API class with credentials set for testing""" assert (os.environ.get('GC_TESTS_PRIVATE_KEY') is not None ), 'GC_TESTS_PRIVATE_KEY not set in environment for trading API\ tests' assert (os.environ.get('GC_TESTS_PUBLIC_KEY') is not None), 'GC_TESTS_PUBLIC_KEY not set in environment for\ trading API tests' return GatecoinAPI(os.environ.get('GC_TESTS_PRIVATE_KEY'), os.environ.get('GC_TESTS_PUBLIC_KEY'))
def test_get_order_book(api: GatecoinAPI): """Test fetching order book from REST API""" response = GatecoinAPI().get_order_book('BTCUSD') assert (response is not None), 'Response did not deserialize properly' # Disabled for now, v1 does not return response_status for this method # assert (response.response_status.message == 'OK'), 'API response not successful' assert (response.asks is not None), 'Asks list does not exist' assert (response.bids is not None), 'Bids list does not exist' assert (len(response.asks) > 0), 'Empty asks list' assert (len(response.bids) > 0), 'Empty bids list' for limit in response.asks: _test_limit(limit) for limit in response.bids: _test_limit(limit)
def test_get_market_depth(api: GatecoinAPI): """Test fetching market depth info from REST API""" response = GatecoinAPI().get_market_depth('BTCUSD') assert (response is not None), 'Response did not deserialize properly' assert (response.response_status is not None), 'Response status does not exist' assert (response.asks is not None), 'Asks list does not exist' assert (response.bids is not None), 'Bids list does not exist' assert (response.response_status.message == 'OK' ), 'API response not successful' assert (len(response.asks) > 0), 'Empty asks list' assert (len(response.bids) > 0), 'Empty bids list' for limit in response.asks: _test_limit(limit) for limit in response.bids: _test_limit(limit)
def test_get_currency_pairs(api: GatecoinAPI): """Test currency pairs fetching from REST API""" response = GatecoinAPI().get_currency_pairs() assert (response is not None), 'Response did not deserialize properly' assert (response.response_status is not None), 'Response status does not exist' assert (response.currency_pairs is not None), 'Currency pairs list does not exist' assert (response.response_status is not None), 'Response status did not deserialize successfully' assert ( response.currency_pairs is not None), 'Currency pairs list did not deserialize successfully' assert (response.response_status.message == 'OK' ), 'API response not successful' assert (len(response.currency_pairs) > 0), 'Empty currency pairs list' for currency_pair in response.currency_pairs: _test_currency_pair(currency_pair)
def api() -> GatecoinAPI: """Fixture to return API class with credentials set for testing""" return GatecoinAPI()