Ejemplo 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 len(self.events) == 7
        assert len(self.dispatcher._handlers) == 6

        del a.one.two[0].one
        # a.unlink()
        watcher.unsubscribe_all()
        watcher.unsubscribe_all()
        assert len(self.dispatcher._handlers) == 0
Ejemplo n.º 2
0
    def test_cyclic(self):
        """Test cyclic dependency a -> b -> c -> a."""
        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

        assert 4 == len(self.events)

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

        a.unlink()
        assert 1 == len(self.dispatcher._handlers)
Ejemplo n.º 3
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 len(self.events) == 6

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