| Total Complexity | 3 |
| Total Lines | 64 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | from tests import APITestCase, mainnet_client |
||
| 2 | |||
| 3 | |||
| 4 | class TestTradeHubGetPrices(APITestCase): |
||
| 5 | |||
| 6 | def setUp(self) -> None: |
||
| 7 | self._client = mainnet_client |
||
| 8 | |||
| 9 | def test_get_prices_structure(self): |
||
| 10 | """ |
||
| 11 | Check if response match expected dict structure. |
||
| 12 | :return: |
||
| 13 | """ |
||
| 14 | |||
| 15 | expect: dict = { |
||
| 16 | "last": str, |
||
| 17 | "index": str, |
||
| 18 | "fair": str, |
||
| 19 | "mark": str, |
||
| 20 | "mark_avg": str, |
||
| 21 | "settlement": str, |
||
| 22 | "fair_index_delta_avg": str, |
||
| 23 | "market": str, |
||
| 24 | "marking_strategy": str, |
||
| 25 | "index_updated_at": str, |
||
| 26 | "last_updated_at": str, |
||
| 27 | "block_height": int |
||
| 28 | } |
||
| 29 | |||
| 30 | result: dict = self._client.get_prices("swth_eth1") |
||
| 31 | |||
| 32 | self.assertDictStructure(expect, result) |
||
| 33 | |||
| 34 | # Currently the field market is empty, check if this changed |
||
| 35 | self.assertTrue(len(result["market"]) == 0, msg="Expected field 'market' to be empty") |
||
| 36 | |||
| 37 | def test_get_prices_empty_structure(self): |
||
| 38 | """ |
||
| 39 | Check if response match expected dict structure. |
||
| 40 | :return: |
||
| 41 | """ |
||
| 42 | |||
| 43 | expect: dict = { |
||
| 44 | "last": str, |
||
| 45 | "index": str, |
||
| 46 | "fair": str, |
||
| 47 | "mark": str, |
||
| 48 | "mark_avg": str, |
||
| 49 | "settlement": str, |
||
| 50 | "fair_index_delta_avg": str, |
||
| 51 | "market": str, |
||
| 52 | "marking_strategy": str, |
||
| 53 | "index_updated_at": str, |
||
| 54 | "last_updated_at": str, |
||
| 55 | "block_height": int |
||
| 56 | } |
||
| 57 | |||
| 58 | result: dict = self._client.get_prices("swth_eth1") |
||
| 59 | |||
| 60 | self.assertDictStructure(expect, result) |
||
| 61 | |||
| 62 | # Currently the field market is empty, check if this changed |
||
| 63 | self.assertTrue(len(result["market"]) == 0, msg="Expected field 'market' to be empty") |
||
| 64 |