Failed Conditions
Pull Request — master (#2076)
by Abdeali
02:11
created

DictUtilitiesTest.test_update_ordered_dict_key()   A

Complexity

Conditions 1

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 1
dl 0
loc 18
rs 9.4285
1
import unittest
2
from collections import OrderedDict
3
4
from coalib.misc.DictUtilities import inverse_dicts, update_ordered_dict_key
5
6
7
class DictUtilitiesTest(unittest.TestCase):
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable unittest does not seem to be defined.
Loading history...
8
9
    def test_inverse_dicts(self):
10
        self.dict1 = {1: [1, 2, 3], 2: [3, 4, 5]}
11
        self.dict2 = {2: [1], 3: [2], 4: [3, 4]}
12
        self.dict3 = {1: 2, 3: 4, 4: 4, 5: 4}
13
        self.dict4 = {2: 3, 4: 4}
14
        result = inverse_dicts(self.dict3)
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable self does not seem to be defined.
Loading history...
15
        self.assertEqual({2: [1], 4: [3, 4, 5]}, result)
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable result does not seem to be defined.
Loading history...
16
17
        result = inverse_dicts(self.dict1)
18
        self.assertEqual({1: [1], 2: [1], 3: [1, 2], 4: [2], 5: [2]}, result)
19
20
        result = inverse_dicts(self.dict3, self.dict4)
21
        self.assertEqual({2: [1], 3: [2], 4: [3, 4, 5, 4]}, result)
22
23
        result = inverse_dicts(self.dict1, self.dict2)
24
        self.assertEqual({1: [1, 2],
25
                          2: [1, 3],
26
                          3: [1, 2, 4],
27
                          4: [2, 4],
28
                          5: [2]}, result)
29
30
    def test_update_ordered_dict_key(self):
31
        self.ordered_dict = OrderedDict()
32
        self.ordered_dict["default"] = "Some stuff"
33
        self.ordered_dict["pythoncheck"] = "Somemore stuff"
34
        self.ordered_dict = update_ordered_dict_key(self.ordered_dict,
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable self does not seem to be defined.
Loading history...
35
                                                    "default",
36
                                                    "coala")
37
        self.assertTrue("coala" in self.ordered_dict)
38
        self.assertEqual("OrderedDict([('coala', 'Some stuff'), "
39
                         "('pythoncheck', 'Somemore stuff')])",
40
                         self.ordered_dict.__str__())
41
        self.ordered_dict = update_ordered_dict_key(self.ordered_dict,
42
                                                    "coala",
43
                                                    "section")
44
        self.assertTrue("section" in self.ordered_dict)
45
        self.assertEqual("OrderedDict([('section', 'Some stuff'), "
46
                         "('pythoncheck', 'Somemore stuff')])",
47
                         self.ordered_dict.__str__())
48