Esempio n. 1
0
    def test_braking_big_diamond(self):
        """
        Test diamond shaped dependencies a -> b -> c -> d, a -> b' -> c' -> d
        """
        A = self.A
        a = A()
        watcher = EventWatcher(a, self.dispatcher, self._handler)
        watcher.watch("one.two.one.two")
        # watcher.watch('one.one.one.one')
        watcher.subscribe_all()

        a.one = A()
        a.one.two = A()
        a.one.two = A()
        a.one.two[0].one = A()
        a.one.two[1].one = A()
        a.one.two[0].one.two = A()
        a.one.two[1].one.two = a.one.two[0].one.two[0]

        assert 7 == len(self.events)
        assert 6 == len(self.dispatcher._handlers)

        del a.one.two[0].one
        # a.unlink()
        watcher.unsubscribe_all()
        watcher.unsubscribe_all()
        assert 0 == len(self.dispatcher._handlers)
Esempio n. 2
0
    def test_diamond(self):
        """
        Test diamond shaped dependencies a -> b -> c, a -> b' -> c
        """
        A = self.A
        a = A()
        watcher = EventWatcher(a, self.dispatcher, self._handler)
        watcher.watch("one.two.one.two")
        # watcher.watch('one.one.one.one')
        watcher.subscribe_all()

        a.one = A()
        a.one.two = A()
        a.one.two = A()
        a.one.two[0].one = A()
        a.one.two[1].one = a.one.two[0].one
        a.one.two[0].one.two = A()

        assert 6 == len(self.events)

        a.unlink()
        watcher.unsubscribe_all()
        watcher.unsubscribe_all()