Passed
Push — master ( 272d30...b93c80 )
by Steffen
01:01
created

TestItem.test_item()   B

Complexity

Conditions 1

Size

Total Lines 32

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
c 1
b 0
f 1
dl 0
loc 32
rs 8.8571
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
            app_id=730,
34
            class_id=12345,
35
            context_id=2,
36
            instance_id=54321,
37
            price=109999,
38
            wear_value=0.14305446,
39
            image="some_item_image_link",
40
            inspect_link="some_steam_inspect_link"
41
        )
42
43
        item_1.add_sticker(self._sticker)
44
45
        item_2 = Item(
46
            app_id=730,
47
            class_id=12345,
48
            context_id=2,
49
            instance_id=54321,
50
            price=109999,
51
            wear_value=0.14305446,
52
            image="some_item_image_link",
53
            inspect_link="some_steam_inspect_link",
54
            stickers=[self._sticker]
55
        )
56
57
        # check if stickers added at a later moment are added properly
58
        self.assertEqual(json.dumps(item_1.__dict__), json.dumps(item_2.__dict__))
59
60
61
if __name__ == '__main__':
62
    suite = unittest.TestLoader().loadTestsFromTestCase(TestItem)
63
    unittest.TextTestRunner(verbosity=2).run(suite)
64