Test Setup Failed
Push — master ( ba0340...40c258 )
by Ken M.
52s
created

Tests.test_Add()   A

Complexity

Conditions 4

Size

Total Lines 9

Duplication

Lines 9
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
c 1
b 0
f 0
dl 9
loc 9
rs 9.2
1
import unittest
2
from friends import Friends
3
4
5
class Tests(unittest.TestCase):
6
    def test_Init(self):
7
        Friends(({"a", "b"}, {"b", "c"}, {"c", "a"}, {"a", "c"}))
8
        Friends([{"1", "2"}, {"3", "1"}])
9
10 View Code Duplication
    def test_Add(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
11
        f = Friends([{"1", "2"}, {"3", "1"}])
12
        assert f.add({"2", "4"}) is True
13
14
        f = Friends([{"And", "Or"}, {"For", "And"}])
15
        assert f.add({"It", "Am"}) is True
16
17
        f = Friends([{"And", "Or"}, {"For", "And"}])
18
        assert f.add({"Or", "And"}) is False
19
20 View Code Duplication
    def test_Remove(self):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
21
        f = Friends([{"1", "2"}, {"3", "1"}])
22
        assert f.remove({"2", "4"}) is False
23
24
        f = Friends([{"1", "2"}, {"3", "1"}])
25
        assert f.remove({"11", "12"}) is False
26
27
        f = Friends([{"And", "Or"}, {"For", "And"}])
28
        assert f.remove({"And", "Or"}) is True
29
30
    def test_Names(self):
31
        f = Friends(({"nikola", "sophia"},
32
                     {"stephen", "robot"},
33
                     {"sophia", "pilot"}))
34
        n = f.names()
35
        assert n == {"nikola", "sophia", "robot", "pilot", "stephen"}
36
37
        f = Friends(({"nikola", "sophia"},
38
                     {"stephen", "robot"},
39
                     {"sophia", "pilot"}))
40
        f.remove({"stephen", "robot"})
41
        n = f.names()
42
        assert n == {"nikola", "sophia", "pilot"}
43
44
    def test_Connected(self):
45
        f = Friends(({"nikola", "sophia"},
46
                     {"stephen", "robot"},
47
                     {"sophia", "pilot"}))
48
        n = f.connected("nikola")
49
        assert n == {"sophia"}
50
51
        f = Friends(({"nikola", "sophia"},
52
                     {"stephen", "robot"},
53
                     {"sophia", "pilot"}))
54
        n = f.connected("sophia")
55
        assert n == {"nikola", "pilot"}
56
57
        f = Friends(({"nikola", "sophia"},
58
                     {"stephen", "robot"},
59
                     {"sophia", "pilot"}))
60
        n = f.connected("DDD")
61
        assert n == set()
62
63
        f = Friends(({"nikola", "sophia"},
64
                     {"stephen", "robot"},
65
                     {"sophia", "pilot"}))
66
        f.add({"sophia", "stephen"})
67
        f.remove({"sophia", "nikola"})
68
        n = f.connected("sophia")
69
        assert n == {"stephen", "pilot"}
70