Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from binance.client import Client
from binance.exceptions import BinanceAPIException, BinanceRequestException
import pytest
import requests_mock


@pytest.fixture(scope='module')
def client():
"""setup"""

client = Client('api_key', 'api_secret')
return client


@requests_mock.Mocker(kw='mock')
def test_get_all_tickers(client, **kwargs):
expected_response = [{'symbol': 'ETHBTC', 'price': '0.06675400'},
{'symbol': 'LTCBTC', 'price': '0.00451500'}]

kwargs['mock'].get('https://api.binance.com/api/v3/ticker/price', json=expected_response)
returned_value = client.get_all_tickers()
assert returned_value == expected_response


@requests_mock.Mocker(kw='mock')
def test_failed_get_all_tickers(client, **kwargs):
with pytest.raises(BinanceAPIException):
kwargs['mock'].get('https://api.binance.com/api/v3/ticker/price', status_code=400)
client.get_all_tickers()