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")])
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)])