Total Complexity | 3 |
Total Lines | 39 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | from tests import APITestCase, mainnet_client |
||
2 | |||
3 | |||
4 | class TestTradeHubGetCandlesticks(APITestCase): |
||
5 | |||
6 | def setUp(self) -> None: |
||
7 | self._client = mainnet_client |
||
8 | |||
9 | def test_get_candlesticks_structure(self): |
||
10 | """ |
||
11 | Check if response match expected dict structure. |
||
12 | :return: |
||
13 | """ |
||
14 | expect: dict = { |
||
15 | "id": int, |
||
16 | "market": str, |
||
17 | "time": str, |
||
18 | "resolution": int, |
||
19 | "open": str, |
||
20 | "close": str, |
||
21 | "high": str, |
||
22 | "low": str, |
||
23 | "volume": str, |
||
24 | "quote_volume": str |
||
25 | } |
||
26 | |||
27 | granularity: int = 5 # 5 minutes |
||
28 | market: str = "swth_eth1" |
||
29 | open_time: int = 1610203000 |
||
30 | close_time: int = 1610203000 + granularity * 60 # add 5minutes |
||
31 | |||
32 | result: list = self._client.get_candlesticks(market, granularity, open_time, close_time) |
||
33 | |||
34 | # With 5 minutes granularity we expect just one candle |
||
35 | self.assertEqual(1, len(result), msg="Expected count(1) of candlesticks are not returned.") |
||
36 | |||
37 | for candle in result: |
||
38 | self.assertDictStructure(expect, candle) |
||
39 |