| Total Complexity | 2 |
| Total Lines | 38 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | # !/usr/bin/python |
||
| 14 | class TestSearchResponse(unittest.TestCase): |
||
| 15 | """ |
||
| 16 | Test cases for the search response model like proper JSON dump and ability to parse to APIResponse object |
||
| 17 | """ |
||
| 18 | |||
| 19 | def setUp(self): |
||
| 20 | """Set up the item to add |
||
| 21 | |||
| 22 | :return: |
||
| 23 | """ |
||
| 24 | sticker = Sticker( |
||
| 25 | name="Howling Dawn", |
||
| 26 | image="some_sticker_image_link", |
||
| 27 | wear_value=0.43092 |
||
| 28 | ) |
||
| 29 | |||
| 30 | self._item = Item( |
||
| 31 | app_id=730, |
||
| 32 | class_id=12345, |
||
| 33 | context_id=2, |
||
| 34 | instance_id=54321, |
||
| 35 | price=109999, |
||
| 36 | wear_value=0.14305446, |
||
| 37 | image="some_item_image_link", |
||
| 38 | inspect_link="some_steam_inspect_link", |
||
| 39 | stickers=[sticker] |
||
| 40 | ) |
||
| 41 | |||
| 42 | def test_response(self): |
||
| 43 | """Test the conversion to the APIResponse object and the json.dumps |
||
| 44 | |||
| 45 | :return: |
||
| 46 | """ |
||
| 47 | response = SearchResponse(success=True, checked_time=time()) |
||
| 48 | response.add_item(self._item) |
||
| 49 | json_response_dump = json.dumps(response.__dict__) |
||
| 50 | api_response = APIResponse(json_response_dump) |
||
| 51 | self.assertEqual(api_response.data.status, True) |
||
| 52 | |||
| 57 |