コード例 #1
0
ファイル: tests.py プロジェクト: BackupTheBerlios/pida-svn
    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, [])
コード例 #2
0
ファイル: tests.py プロジェクト: BackupTheBerlios/pida-svn
    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")])
コード例 #3
0
ファイル: tests.py プロジェクト: BackupTheBerlios/pida-svn
    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")])
コード例 #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)])
コード例 #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)])
コード例 #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, [])
コード例 #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")])
コード例 #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")])
コード例 #9
0
ファイル: tests.py プロジェクト: BackupTheBerlios/pida-svn
    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)])
コード例 #10
0
ファイル: tests.py プロジェクト: BackupTheBerlios/pida-svn
    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)])