Beispiel #1
0
    def test_Names(self):
        f = Friends(({"nikola", "sophia"}, {"stephen", "robot"}, {"sophia", "pilot"}))
        n = f.names()
        assert n == {"nikola", "sophia", "robot", "pilot", "stephen"}

        f = Friends(({"nikola", "sophia"}, {"stephen", "robot"}, {"sophia", "pilot"}))
        f.remove({"stephen", "robot"})
        n = f.names()
        assert n == {"nikola", "sophia", "pilot"}
Beispiel #2
0
    def test_Remove(self):
        f = Friends([{"1", "2"}, {"3", "1"}])
        assert f.remove({"2", "4"}) is False

        f = Friends([{"1", "2"}, {"3", "1"}])
        assert f.remove({"11", "12"}) is False

        f = Friends([{"And", "Or"}, {"For", "And"}])
        assert f.remove({"And", "Or"}) is True
Beispiel #3
0
    def test_Connected(self):
        f = Friends(({"nikola", "sophia"}, {"stephen", "robot"}, {"sophia", "pilot"}))
        n = f.connected("nikola")
        assert n == {"sophia"}

        f = Friends(({"nikola", "sophia"}, {"stephen", "robot"}, {"sophia", "pilot"}))
        n = f.connected("sophia")
        assert n == {"nikola", "pilot"}

        f = Friends(({"nikola", "sophia"}, {"stephen", "robot"}, {"sophia", "pilot"}))
        n = f.connected("DDD")
        assert n == set()

        f = Friends(({"nikola", "sophia"}, {"stephen", "robot"}, {"sophia", "pilot"}))
        f.add({"sophia", "stephen"})
        f.remove({"sophia", "nikola"})
        n = f.connected("sophia")
        assert n == {"stephen", "pilot"}