test_find_friends.Tests.test_Edge()   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
import unittest
2
3
from find_friends import check_connection
4
5
6
class Tests(unittest.TestCase):
7
    TESTS = {
8
        "Basics": [
9
            {
10
                "input": (
11
                    (
12
                        "dr101-mr99",
13
                        "mr99-out00",
14
                        "dr101-out00",
15
                        "scout1-scout2",
16
                        "scout3-scout1",
17
                        "scout1-scout4",
18
                        "scout4-sscout",
19
                        "sscout-super",
20
                    ),
21
                    "scout2",
22
                    "scout3",
23
                ),
24
                "answer": True,
25
                "explanation": [
26
                    "dr101",
27
                    "mr99",
28
                    "out00",
29
                    "scout1",
30
                    "scout2",
31
                    "scout3",
32
                    "scout4",
33
                    "sscout",
34
                    "super",
35
                ],
36
            },
37
            {
38
                "input": (
39
                    (
40
                        "dr101-mr99",
41
                        "mr99-out00",
42
                        "dr101-out00",
43
                        "scout1-scout2",
44
                        "scout3-scout1",
45
                        "scout1-scout4",
46
                        "scout4-sscout",
47
                        "sscout-super",
48
                    ),
49
                    "super",
50
                    "scout2",
51
                ),
52
                "answer": True,
53
                "explanation": [
54
                    "dr101",
55
                    "mr99",
56
                    "out00",
57
                    "scout1",
58
                    "scout2",
59
                    "scout3",
60
                    "scout4",
61
                    "sscout",
62
                    "super",
63
                ],
64
            },
65
            {
66
                "input": (
67
                    (
68
                        "dr101-mr99",
69
                        "mr99-out00",
70
                        "dr101-out00",
71
                        "scout1-scout2",
72
                        "scout3-scout1",
73
                        "scout1-scout4",
74
                        "scout4-sscout",
75
                        "sscout-super",
76
                    ),
77
                    "dr101",
78
                    "sscout",
79
                ),
80
                "answer": False,
81
                "explanation": [
82
                    "dr101",
83
                    "mr99",
84
                    "out00",
85
                    "scout1",
86
                    "scout2",
87
                    "scout3",
88
                    "scout4",
89
                    "sscout",
90
                    "super",
91
                ],
92
            },
93
        ],
94
        "Edge": [
95
            {
96
                "input": (['night-nikola'], "nikola", "night"),
97
                "answer": True,
98
                "explanation": None,
99
            },
100
            {
101
                "input": (['nic-batman', 'cat-super'], "batman", "cat"),
102
                "answer": False,
103
                "explanation": ['batman', 'cat', 'super', 'nic'],
104
            },
105
            {
106
                "input": (
107
                    [
108
                        'scout1-scout3',
109
                        'plane1-robin',
110
                        'scout3-sscout',
111
                        'scout1-base',
112
                        'pingin-scout1',
113
                        'sscout-base',
114
                        'scout3-plane1',
115
                        'scout3-robin',
116
                        'plane1-nikola',
117
                        'plane1-pingin',
118
                        'base-scout3',
119
                        'plane1-sobhia',
120
                        'base-pingin',
121
                        'scout3-sobhia',
122
                        'robin-stevan',
123
                        'robin-base',
124
                        'nikola-robin',
125
                        'sobhia-sscout',
126
                        'stevan-sscout',
127
                        'robin-sobhia',
128
                        'robin-sscout',
129
                        'pingin-sscout',
130
                        'scout3-nikola',
131
                        'nikola-base',
132
                        'plane1-scout1',
133
                        'plane1-base',
134
                        'sscout-plane1',
135
                        'sobhia-scout1',
136
                        'sscout-scout1',
137
                        'robin-pingin',
138
                        'pingin-stevan',
139
                        'pingin-sobhia',
140
                        'scout3-pingin',
141
                        'nikola-sscout',
142
                        'nikola-pingin',
143
                        'stevan-base',
144
                        'stevan-scout1',
145
                        'scout1-nikola',
146
                        'nikola-sobhia',
147
                        'stevan-sobhia',
148
                        'stevan-scout3',
149
                        'scout1-robin',
150
                        'nikola-stevan',
151
                        'sobhia-base',
152
                        'stevan-plane1',
153
                    ],
154
                    "pingin",
155
                    "sobhia",
156
                ),
157
                "answer": True,
158
                "explanation": [
159
                    'pingin',
160
                    'sobhia',
161
                    'sscout',
162
                    'scout3',
163
                    'stevan',
164
                    'scout1',
165
                    'plane1',
166
                    'nikola',
167
                    'base',
168
                    'robin',
169
                ],
170
            },
171
            {
172
                "input": (
173
                    [
174
                        'sscout-batman',
175
                        'plane1-scout3',
176
                        'stevan-batman',
177
                        'super-sscout',
178
                        'scout2-batman',
179
                        'scout2-sscout',
180
                        'doc-mega',
181
                        'night-batman',
182
                        'scout3-doc',
183
                    ],
184
                    "scout2",
185
                    "plane1",
186
                ),
187
                "answer": False,
188
                "explanation": [
189
                    'scout2',
190
                    'plane1',
191
                    'stevan',
192
                    'night',
193
                    'mega',
194
                    'sscout',
195
                    'super',
196
                    'scout3',
197
                    'doc',
198
                    'batman',
199
                ],
200
            },
201
            {
202
                "input": (
203
                    [
204
                        'scout2-plane1',
205
                        'plane1-stevan',
206
                        'stevan-night',
207
                        'night-mega',
208
                        'mega-sscout',
209
                        'sscout-super',
210
                        'super-scout3',
211
                        'scout3-doc',
212
                        'doc-batman',
213
                    ],
214
                    "scout2",
215
                    "batman",
216
                ),
217
                "answer": True,
218
                "explanation": [
219
                    'scout2',
220
                    'plane1',
221
                    'stevan',
222
                    'night',
223
                    'mega',
224
                    'sscout',
225
                    'super',
226
                    'scout3',
227
                    'doc',
228
                    'batman',
229
                ],
230
            },
231
            {
232
                "input": (
233
                    [
234
                        'scout2-plane1',
235
                        'plane1-stevan',
236
                        'stevan-night',
237
                        'night-mega',
238
                        'sscout-super',
239
                        'super-scout3',
240
                        'scout3-doc',
241
                        'doc-batman',
242
                    ],
243
                    "night",
244
                    "batman",
245
                ),
246
                "answer": False,
247
                "explanation": [
248
                    'scout2',
249
                    'plane1',
250
                    'stevan',
251
                    'night',
252
                    'mega',
253
                    'sscout',
254
                    'super',
255
                    'scout3',
256
                    'doc',
257
                    'batman',
258
                ],
259
            },
260
            {
261
                "input": (
262
                    [
263
                        'scout1-scout3',
264
                        'plane1-robin',
265
                        'scout3-sscout',
266
                        'pingin-scout1',
267
                        'scout3-plane1',
268
                        'scout3-robin',
269
                        'plane1-nikola',
270
                        'plane1-pingin',
271
                        'plane1-sobhia',
272
                        'scout3-sobhia',
273
                        'nikola-robin',
274
                        'sobhia-sscout',
275
                        'robin-sobhia',
276
                        'robin-sscout',
277
                        'pingin-sscout',
278
                        'scout3-nikola',
279
                        'plane1-scout1',
280
                        'sscout-plane1',
281
                        'sobhia-scout1',
282
                        'sscout-scout1',
283
                        'robin-pingin',
284
                        'pingin-sobhia',
285
                        'scout3-pingin',
286
                        'nikola-sscout',
287
                        'nikola-pingin',
288
                        'stevan-base',
289
                        'scout1-nikola',
290
                        'nikola-sobhia',
291
                        'scout1-robin',
292
                    ],
293
                    "base",
294
                    "nikola",
295
                ),
296
                "answer": False,
297
                "explanation": [
298
                    'pingin',
299
                    'sobhia',
300
                    'sscout',
301
                    'scout3',
302
                    'stevan',
303
                    'scout1',
304
                    'plane1',
305
                    'nikola',
306
                    'base',
307
                    'robin',
308
                ],
309
            },
310
        ],
311
        "Extra": [
312
            {
313
                "input": (['mr99-cat', 'mega-mr99'], "cat", "mr99"),
314
                "answer": True,
315
                "explanation": ['cat', 'mr99', 'mega'],
316
            },
317
            {
318
                "input": (
319
                    ['cat-super', 'cat-nikola', 'nikola-super'],
320
                    "nikola",
321
                    "super",
322
                ),
323
                "answer": True,
324
                "explanation": ['nikola', 'super', 'cat'],
325
            },
326
            {
327
                "input": (
328
                    [
329
                        'nikola-robin',
330
                        'batman-nwing',
331
                        'mr99-batman',
332
                        'mr99-robin',
333
                        'dr101-out00',
334
                        'out00-nwing',
335
                    ],
336
                    "dr101",
337
                    "mr99",
338
                ),
339
                "answer": True,
340
                "explanation": [
341
                    'dr101',
342
                    'mr99',
343
                    'out00',
344
                    'nikola',
345
                    'robin',
346
                    'batman',
347
                    'nwing',
348
                ],
349
            },
350
            {
351
                "input": (
352
                    [
353
                        'cat-robin',
354
                        'cat-base',
355
                        'out00-scout4',
356
                        'robin-scout4',
357
                        'cat-batman',
358
                        'batman-plane2',
359
                        'plane2-scout3',
360
                        'plane2-base',
361
                        'robin-batman',
362
                        'mr99-scout3',
363
                    ],
364
                    "base",
365
                    "robin",
366
                ),
367
                "answer": True,
368
                "explanation": [
369
                    'base',
370
                    'robin',
371
                    'mr99',
372
                    'scout3',
373
                    'plane2',
374
                    'batman',
375
                    'cat',
376
                    'scout4',
377
                    'out00',
378
                ],
379
            },
380
            {
381
                "input": (
382
                    ['out00-scout3', 'mega-scout3', 'mega-robin'],
383
                    "robin",
384
                    "out00",
385
                ),
386
                "answer": True,
387
                "explanation": ['scout3', 'out00', 'mega', 'robin'],
388
            },
389
            {
390
                "input": (
391
                    [
392
                        'base-night',
393
                        'scout1-night',
394
                        'pingin-sscout',
395
                        'sscout-scout1',
396
                        'dr101-pingin',
397
                        'sscout-base',
398
                        'dr101-sscout',
399
                        'pingin-night',
400
                        'pingin-scout1',
401
                        'scout1-dr101',
402
                        'dr101-night',
403
                    ],
404
                    "pingin",
405
                    "base",
406
                ),
407
                "answer": True,
408
                "explanation": ['pingin', 'base', 'night', 'dr101', 'sscout', 'scout1'],
409
            },
410
            {
411
                "input": (
412
                    ['base-nikola', 'scout1-nikola', 'nikola-nwing'],
413
                    "nwing",
414
                    "base",
415
                ),
416
                "answer": True,
417
                "explanation": ['nwing', 'base', 'scout1', 'nikola'],
418
            },
419
            {
420
                "input": (
421
                    ['base-stevan', 'out00-stevan', 'dr101-nwing'],
422
                    "nwing",
423
                    "out00",
424
                ),
425
                "answer": False,
426
                "explanation": ['nwing', 'out00', 'dr101', 'base', 'stevan'],
427
            },
428
            {
429
                "input": (['sobhia-mega', 'nwing-nikola'], "nwing", "mega"),
430
                "answer": False,
431
                "explanation": ['nwing', 'mega', 'nikola', 'sobhia'],
432
            },
433
            {
434
                "input": (
435
                    ['pingin-out00', 'night-plane2', 'pingin-scout3'],
436
                    "plane2",
437
                    "out00",
438
                ),
439
                "answer": False,
440
                "explanation": ['plane2', 'out00', 'night', 'scout3', 'pingin'],
441
            },
442
            {
443
                "input": (
444
                    [
445
                        'out00-nwing',
446
                        'scout1-night',
447
                        'out00-sscout',
448
                        'scout4-night',
449
                        'nwing-sscout',
450
                        'plane1-scout1',
451
                    ],
452
                    "nwing",
453
                    "night",
454
                ),
455
                "answer": False,
456
                "explanation": [
457
                    'nwing',
458
                    'night',
459
                    'plane1',
460
                    'scout1',
461
                    'sscout',
462
                    'out00',
463
                    'scout4',
464
                ],
465
            },
466
        ],
467
    }
468
469
    def test_Basics(self):
470
        for i in self.TESTS['Basics']:
471
            assert check_connection(*i['input']) == i['answer'], i['input']
472
473
    def test_Edge(self):
474
        for i in self.TESTS['Edge']:
475
            assert check_connection(*i['input']) == i['answer'], i['input']
476
477
    def test_Extra(self):
478
        for i in self.TESTS['Extra']:
479
            assert check_connection(*i['input']) == i['answer'], i['input']
480
481
482
if __name__ == "__main__":  # pragma: no cover
483
    unittest.main()
484