Exemplo n.º 1
0
    def test_nill_matcher(self):
        vals = self.vals
        a1 = BlahModel()
        obs = MatchObserver()
        obs.set_model(a1)
        obs.register(lambda attr: False, self.on_foo)

        a1.meh__foo = 100
        self.assertEqual(vals, [])

        a1.feh__gah = "coiso"
        self.assertEqual(vals, [])
Exemplo n.º 2
0
    def test_all_matcher(self):
        vals = self.vals
        a1 = BlahModel()
        obs = MatchObserver()
        obs.set_model(a1)
        obs.register(lambda attr: True, self.on_foo)

        a1.meh__foo = 100
        self.assertEqual(vals, [("meh__foo", 100)])

        a1.feh__gah = "coiso"
        self.assertEqual(vals, [("meh__foo", 100), ("feh__gah", "coiso")])
Exemplo n.º 3
0
    def test_glob(self):
        vals = self.vals
        a1 = BlahModel()
        obs = MatchObserver()
        obs.set_model(a1)
        obs.connect("*", self.on_foo)

        a1.meh__foo = 100
        self.assertEqual(vals, [("meh__foo", 100)])

        a1.feh__gah = "coiso"
        self.assertEqual(vals, [("meh__foo", 100), ("feh__gah", "coiso")])
Exemplo n.º 4
0
    def test_connection(self):
        vals = self.vals
        a1 = BlahModel()
        obs = MatchObserver()
        obs.set_model(a1)
        subs = obs.connect("*", self.on_foo)

        a1.meh__foo = 100
        self.assertEqual(vals, [("meh__foo", 100)])

        obs.unregister(subs)
        a1.feh__gah = "coiso"
        self.assertEqual(vals, [("meh__foo", 100)])
Exemplo n.º 5
0
    def test_registration(self):
        vals = self.vals
        a1 = BlahModel()
        obs = MatchObserver()
        obs.set_model(a1)
        subs = obs.register(lambda attr: True, self.on_foo)

        a1.meh__foo = 100
        self.assertEqual(vals, [("meh__foo", 100)])

        obs.unregister(subs)
        a1.feh__gah = "coiso"
        self.assertEqual(vals, [("meh__foo", 100)])
Exemplo n.º 6
0
    def test_nill_matcher(self):
        vals = self.vals
        a1 = BlahModel()
        obs = MatchObserver()
        obs.set_model(a1)
        obs.register(lambda attr: False, self.on_foo)

        a1.meh__foo = 100
        self.assertEqual(vals, [])

        a1.feh__gah = "coiso"
        self.assertEqual(vals, [])
Exemplo n.º 7
0
    def test_all_matcher(self):
        vals = self.vals
        a1 = BlahModel()
        obs = MatchObserver()
        obs.set_model(a1)
        obs.register(lambda attr: True, self.on_foo)

        a1.meh__foo = 100
        self.assertEqual(vals, [("meh__foo", 100)])

        a1.feh__gah = "coiso"
        self.assertEqual(vals, [("meh__foo", 100), ("feh__gah", "coiso")])
Exemplo n.º 8
0
    def test_glob(self):
        vals = self.vals
        a1 = BlahModel()
        obs = MatchObserver()
        obs.set_model(a1)
        obs.connect("*", self.on_foo)

        a1.meh__foo = 100
        self.assertEqual(vals, [("meh__foo", 100)])

        a1.feh__gah = "coiso"
        self.assertEqual(vals, [("meh__foo", 100), ("feh__gah", "coiso")])
Exemplo n.º 9
0
    def test_connection(self):
        vals = self.vals
        a1 = BlahModel()
        obs = MatchObserver()
        obs.set_model(a1)
        subs = obs.connect("*", self.on_foo)

        a1.meh__foo = 100
        self.assertEqual(vals, [("meh__foo", 100)])

        obs.unregister(subs)
        a1.feh__gah = "coiso"
        self.assertEqual(vals, [("meh__foo", 100)])
Exemplo n.º 10
0
    def test_registration(self):
        vals = self.vals
        a1 = BlahModel()
        obs = MatchObserver()
        obs.set_model(a1)
        subs = obs.register(lambda attr: True, self.on_foo)

        a1.meh__foo = 100
        self.assertEqual(vals, [("meh__foo", 100)])

        obs.unregister(subs)
        a1.feh__gah = "coiso"
        self.assertEqual(vals, [("meh__foo", 100)])