Passed
Pull Request — main (#42)
by Switcheolytics
55s
created

tests.test_tradehub_get_candlesticks   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 25
dl 0
loc 39
rs 10
c 0
b 0
f 0
wmc 3
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