Skip to content

Commit 34c8dfd

Browse files
committed
chore: add call tests
1 parent 3684107 commit 34c8dfd

File tree

2 files changed

+100
-5
lines changed

2 files changed

+100
-5
lines changed

README.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ This package is compatible with Python v3.8+.
1515
- [Environment Variables](#environment-variables)
1616
- [Quickstart](#quickstart)
1717
- [Local Development](#local-development)
18-
- [Setup](#setup)
19-
- [Testing](#testing)
18+
- [Testing](#testing)
2019
- [Links](#links)
2120
- [Contributing](#contributing)
2221
- [License](#license)
@@ -79,11 +78,11 @@ naver = Naver(api_key=api_key)
7978

8079
## Local Development
8180

82-
### Setup
83-
8481
If you wish to work on local development please clone/fork the git repo and use `pip install -r requirements.txt` to setup the project.
8582

86-
### Testing
83+
## Testing
84+
85+
### Unit tests
8786

8887
```shell
8988
# In case packages are not installed yet
@@ -92,6 +91,12 @@ pip3 install -r requirements/requirements-test.txt
9291
python3 -m pytest tests/
9392
```
9493

94+
### Test calls
95+
96+
```shell
97+
python3 tests/test.py
98+
```
99+
95100
## Links
96101

97102
- [Official Website](https://datamaxiplus.com/)

tests/test_call.py

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import os
2+
import logging
3+
from datamaxi import Datamaxi
4+
5+
6+
logging.basicConfig(level=logging.INFO)
7+
8+
api_key = os.getenv("API_KEY")
9+
base_url = os.getenv("BASE_URL") or "https://api.datamaxiplus.com"
10+
11+
datamaxi = Datamaxi(api_key=api_key, base_url=base_url)
12+
13+
14+
def testcall(func, **kwargs):
15+
name = f"{func.__module__}.{func.__qualname__}"
16+
logging.info(name)
17+
func(**kwargs)
18+
logging.info(f"{name} ok")
19+
20+
21+
logging.info("cex candle")
22+
testcall(
23+
datamaxi.cex.candle,
24+
exchange="binance",
25+
symbol="BTC-USDT",
26+
interval="1m",
27+
market="spot",
28+
)
29+
testcall(datamaxi.cex.candle.exchanges, market="spot")
30+
testcall(datamaxi.cex.candle.symbols, exchange="binance", market="spot")
31+
testcall(datamaxi.cex.candle.intervals)
32+
33+
logging.info("cex ticker")
34+
testcall(datamaxi.cex.ticker.exchanges, market="spot")
35+
testcall(datamaxi.cex.ticker.symbols, exchange="binance", market="spot")
36+
37+
logging.info("cex token updates")
38+
testcall(datamaxi.cex.token.updates)
39+
40+
logging.info("cex fees")
41+
testcall(datamaxi.cex.fee.get, exchange="binance", symbol="BTC-USDT")
42+
testcall(datamaxi.cex.fee.exchanges)
43+
testcall(datamaxi.cex.fee.symbols, exchange="binance")
44+
45+
logging.info("cex announcement")
46+
testcall(datamaxi.cex.announcement.get)
47+
48+
logging.info("cex transfer")
49+
testcall(datamaxi.cex.wallet_status.get, exchange="binance", asset="BTC")
50+
testcall(datamaxi.cex.wallet_status.exchanges)
51+
testcall(datamaxi.cex.wallet_status.assets, exchange="binance")
52+
53+
logging.info("funding rate")
54+
testcall(datamaxi.funding_rate.history, exchange="binance", symbol="BTC-USDT")
55+
testcall(datamaxi.funding_rate.latest, exchange="binance", symbol="BTC-USDT")
56+
testcall(datamaxi.funding_rate.exchanges)
57+
testcall(datamaxi.funding_rate.symbols, exchange="binance")
58+
59+
60+
logging.info("dex")
61+
testcall(datamaxi.dex.chains)
62+
testcall(datamaxi.dex.exchanges)
63+
testcall(datamaxi.dex.pools, exchange="klayswap", chain="kaia_mainnet")
64+
testcall(datamaxi.dex.intervals)
65+
testcall(
66+
datamaxi.dex.trade,
67+
exchange="pancakeswap",
68+
chain="bsc_mainnet",
69+
pool="0xb24cd29e32FaCDDf9e73831d5cD1FFcd1e535423",
70+
)
71+
testcall(
72+
datamaxi.dex.liquidity,
73+
exchange="pancakeswap",
74+
chain="bsc_mainnet",
75+
pool="0xb24cd29e32FaCDDf9e73831d5cD1FFcd1e535423",
76+
)
77+
testcall(
78+
datamaxi.dex.trade,
79+
exchange="pancakeswap",
80+
chain="bsc_mainnet",
81+
pool="0xb24cd29e32FaCDDf9e73831d5cD1FFcd1e535423",
82+
)
83+
84+
logging.info("forex")
85+
testcall(datamaxi.forex.symbols)
86+
testcall(datamaxi.forex, symbol="USD-KRW", pandas=True)
87+
88+
logging.info("premium")
89+
testcall(datamaxi.premium)
90+
testcall(datamaxi.premium.exchanges)

0 commit comments

Comments
 (0)