GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

TestCompletionCompilerValues.test_multiple_title()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 0
loc 19
rs 9.4285
1
"""This module is for testing the completion compilers."""
2
3
4
import sys
5
6
from unittest import TestCase
7
8
COMPLETION_COMPILER = sys.modules["Rainmeter.completion.compiler"]
9
10
11
class TestCompletionCompilerKeys(TestCase):
12
    """Test for the completion key compiler using unittest."""
13
14
    def test_empty_same_size(self):
15
        """."""
16
        options = list()
17
18
        compiled_key = COMPLETION_COMPILER.compile_keys(options)
19
20
        self.assertEqual(len(options), len(compiled_key))
21
22
    def test_title_hint(self):
23
        """."""
24
        options = [
25
            {
26
                "title": "test",
27
                "hint": "hint"
28
            }
29
        ]
30
31
        actual = COMPLETION_COMPILER.compile_keys(options)
32
33
        expected = [
34
            ("test", "test\thint", "test", False)
35
        ]
36
37
        self.assertEqual(actual, expected)
38
39
    def test_multiple_title_hint(self):
40
        """."""
41
        options = [
42
            {
43
                "title": "test",
44
                "hint": "hint"
45
            },
46
            {
47
                "title": "second_title",
48
                "hint": "second_hint"
49
            }
50
        ]
51
52
        actual = COMPLETION_COMPILER.compile_keys(options)
53
54
        expected = [
55
            ("test", "test\thint", "test", False),
56
            ("second_title", "second_title\tsecond_hint", "second_title", False),
57
        ]
58
59
        self.assertEqual(actual, expected)
60
61
    def test_title_hint_value(self):
62
        """."""
63
        options = [
64
            {
65
                "title": "test",
66
                "hint": "hint",
67
                "value": "value"
68
            }
69
        ]
70
71
        actual = COMPLETION_COMPILER.compile_keys(options)
72
73
        expected = [
74
            ("test", "test\thint", "value", False)
75
        ]
76
77
        self.assertEqual(actual, expected)
78
79
    def test_title_hint_value_unique(self):
80
        """."""
81
        options = [
82
            {
83
                "title": "test",
84
                "hint": "hint",
85
                "value": "value",
86
                "unique": True
87
            }
88
        ]
89
90
        actual = COMPLETION_COMPILER.compile_keys(options)
91
92
        expected = [
93
            ("test", "test\thint", "value", True)
94
        ]
95
96
        self.assertEqual(actual, expected)
97
98
    def test_title_hint_unique(self):
99
        """."""
100
        options = [
101
            {
102
                "title": "title",
103
                "hint": "hint",
104
                "unique": True
105
            }
106
        ]
107
108
        actual = COMPLETION_COMPILER.compile_keys(options)
109
110
        expected = [
111
            ("title", "title\thint", "title", True)
112
        ]
113
114
        self.assertEqual(actual, expected)
115
116
117
class TestCompletionCompilerValues(TestCase):
118
    """."""
119
120
    def test_empty(self):
121
        """."""
122
        options = list()
123
124
        compiled_key_values = COMPLETION_COMPILER.compile_values(options)
125
126
        # empty dict evaluates to False -> not False = True
127
        self.assertTrue(not compiled_key_values)
128
129
    def test_title(self):
130
        """."""
131
        options = [
132
            {
133
                "title": "title"
134
            }
135
        ]
136
137
        expected = {
138
            "title": []
139
        }
140
141
        compiled_key_values = COMPLETION_COMPILER.compile_values(options)
142
143
        self.assertEqual(compiled_key_values, expected)
144
145
    def test_multiple_title(self):
146
        """."""
147
        options = [
148
            {
149
                "title": "title"
150
            },
151
            {
152
                "title": "test"
153
            }
154
        ]
155
156
        expected = {
157
            "title": [],
158
            "test": []
159
        }
160
161
        compiled_key_values = COMPLETION_COMPILER.compile_values(options)
162
163
        self.assertEqual(compiled_key_values, expected)
164
165
    def test_title_valuekey(self):
166
        """."""
167
        options = [
168
            {
169
                "title": "title",
170
                "values": [
171
                    ["key"]
172
                ]
173
            }
174
        ]
175
176
        expected = {
177
            "title": [("key\tDefault", "key")]
178
        }
179
180
        compiled_key_values = COMPLETION_COMPILER.compile_values(options)
181
182
        self.assertEqual(compiled_key_values, expected)
183
184
    def test_title_multiple_valuekeys(self):
185
        """."""
186
        options = [
187
            {
188
                "title": "title",
189
                "values": [
190
                    ["key"],
191
                    ["key2"]
192
                ]
193
            }
194
        ]
195
196
        expected = {
197
            "title": [
198
                ("key\tDefault", "key"),
199
                ("key2\tDefault", "key2")
200
            ]
201
        }
202
203
        compiled_key_values = COMPLETION_COMPILER.compile_values(options)
204
205
        self.assertEqual(compiled_key_values, expected)
206
207
    def test_title_key_hint(self):
208
        """."""
209
        options = [
210
            {
211
                "title": "title",
212
                "values": [
213
                    ["key", "hint"]
214
                ]
215
            }
216
        ]
217
218
        expected = {
219
            "title": [("key\thint", "key")]
220
        }
221
222
        compiled_key_values = COMPLETION_COMPILER.compile_values(options)
223
224
        self.assertEqual(compiled_key_values, expected)
225
226
    def test_title_key_hint_value(self):
227
        """."""
228
        options = [
229
            {
230
                "title": "title",
231
                "values": [
232
                    ["key", "hint", "value"]
233
                ]
234
            }
235
        ]
236
237
        expected = {
238
            "title": [("key\thint", "value")]
239
        }
240
241
        compiled_key_values = COMPLETION_COMPILER.compile_values(options)
242
243
        self.assertEqual(compiled_key_values, expected)
244
245
    def test_title_multi_key_hint_value(self):
246
        """."""
247
        options = [
248
            {
249
                "title": "title",
250
                "values": [
251
                    ["default_key"],
252
                    ["hint_key", "hint_hint"],
253
                    ["value_key", "value_hint", "value_content"]
254
                ]
255
            }
256
        ]
257
258
        expected = {
259
            "title": [
260
                ("default_key\tDefault", "default_key"),
261
                ("hint_key\thint_hint", "hint_key"),
262
                ("value_key\tvalue_hint", "value_content"),
263
            ]
264
        }
265
266
        compiled_key_values = COMPLETION_COMPILER.compile_values(options)
267
268
        self.assertEqual(compiled_key_values, expected)
269
270
    def test_invalid_size_low(self):
271
        """."""
272
        options = [
273
            {
274
                "title": "title",
275
                "values": [
276
                    []
277
                ]
278
            }
279
        ]
280
281
        expected = {
282
            "title": [None]
283
        }
284
285
        compiled_key_values = COMPLETION_COMPILER.compile_values(options)
286
287
        self.assertEqual(compiled_key_values, expected)
288
289
    def test_invalid_size_high(self):
290
        """."""
291
        options = [
292
            {
293
                "title": "title",
294
                "values": [
295
                    ["value_key", "value_hint", "value_content", "INVALID_FORTH"]
296
                ]
297
            }
298
        ]
299
300
        expected = {
301
            "title": [None]
302
        }
303
304
        compiled_key_values = COMPLETION_COMPILER.compile_values(options)
305
306
        self.assertEqual(compiled_key_values, expected)
307
308
    def test_all(self):
309
        """."""
310
        options = [
311
            {
312
                "title": "title",
313
                "values": [
314
                    ["default_key"],
315
                    ["hint_key", "hint_hint"],
316
                    ["value_key", "value_hint", "value_content"]
317
                ]
318
            },
319
            {
320
                "title": "different_key",
321
                "values": [
322
                    ["default_key"],
323
                    ["hint_key", "hint_hint"],
324
                    ["value_key", "value_hint", "value_content"]
325
                ]
326
            }
327
        ]
328
329
        expected = {
330
            "title": [
331
                ("default_key\tDefault", "default_key"),
332
                ("hint_key\thint_hint", "hint_key"),
333
                ("value_key\tvalue_hint", "value_content"),
334
            ],
335
            "different_key": [
336
                ("default_key\tDefault", "default_key"),
337
                ("hint_key\thint_hint", "hint_key"),
338
                ("value_key\tvalue_hint", "value_content"),
339
            ],
340
        }
341
342
        compiled_key_values = COMPLETION_COMPILER.compile_values(options)
343
344
        self.assertEqual(compiled_key_values, expected)
345