tests.watcher.adapters.models.test_item   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 40
dl 0
loc 65
rs 10
c 0
b 0
f 0

2 Methods

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