Total Complexity | 2 |
Total Lines | 68 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | # !/usr/bin/python |
||
2 | # -*- coding: utf-8 -*- |
||
3 | |||
4 | import json |
||
5 | import unittest |
||
6 | |||
7 | from kuon.watcher.adapters.models.item import Item |
||
8 | from kuon.watcher.adapters.models.sticker import Sticker |
||
9 | |||
10 | |||
11 | class TestItem(unittest.TestCase): |
||
12 | """ |
||
13 | Test cases for the item model for the properties |
||
14 | """ |
||
15 | |||
16 | def setUp(self): |
||
17 | """Set up the sticker to add |
||
18 | |||
19 | :return: |
||
20 | """ |
||
21 | self._sticker = Sticker( |
||
22 | name="Howling Dawn", |
||
23 | image="some_sticker_image_link", |
||
24 | wear_value=0.43092 |
||
25 | ) |
||
26 | |||
27 | def test_item(self): |
||
28 | """Test the conversion to the APIResponse object and the json.dumps |
||
29 | |||
30 | :return: |
||
31 | """ |
||
32 | item_1 = Item( |
||
33 | market_name='some_market_name', |
||
34 | item_id=12345, |
||
35 | app_id=730, |
||
36 | class_id=12345, |
||
37 | context_id=2, |
||
38 | instance_id=54321, |
||
39 | price=109999, |
||
40 | wear_value=0.14305446, |
||
41 | image="some_item_image_link", |
||
42 | inspect_link="some_steam_inspect_link" |
||
43 | ) |
||
44 | |||
45 | item_1.add_sticker(self._sticker) |
||
46 | |||
47 | item_2 = Item( |
||
48 | market_name='some_market_name', |
||
49 | item_id=12345, |
||
50 | app_id=730, |
||
51 | class_id=12345, |
||
52 | context_id=2, |
||
53 | instance_id=54321, |
||
54 | price=109999, |
||
55 | wear_value=0.14305446, |
||
56 | image="some_item_image_link", |
||
57 | inspect_link="some_steam_inspect_link", |
||
58 | stickers=[self._sticker] |
||
59 | ) |
||
60 | |||
61 | # check if stickers added at a later moment are added properly |
||
62 | self.assertEqual(json.dumps(item_1.__dict__), json.dumps(item_2.__dict__)) |
||
63 | |||
64 | |||
65 | if __name__ == '__main__': |
||
66 | suite = unittest.TestLoader().loadTestsFromTestCase(TestItem) |
||
67 | unittest.TextTestRunner(verbosity=2).run(suite) |
||
68 |