Beispiel #1
0
    def test_Add(self):
        f = Friends([{"1", "2"}, {"3", "1"}])
        assert f.add({"2", "4"}) is True

        f = Friends([{"And", "Or"}, {"For", "And"}])
        assert f.add({"It", "Am"}) is True

        f = Friends([{"And", "Or"}, {"For", "And"}])
        assert f.add({"Or", "And"}) is False
Beispiel #2
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"}