Beispiel #1
0
 def testEventPreventedWhenValueUnchanged(self):
     pm = PropertyLayer()
     pm["testkey"] = "testvalue"
     mock = Mock()
     pm.wire(mock.method)
     pm["testkey"] = "testvalue"
     mock.method.assert_not_called()
Beispiel #2
0
 def testSubscription(self):
     pm = PropertyLayer()
     pm["testkey"] = "before"
     mock = Mock()
     pm.wire(mock.method)
     pm["testkey"] = "after"
     mock.method.assert_called_once_with({"testkey": "after"})
Beispiel #3
0
    def testUnsubscribe(self):
        pm = PropertyLayer()
        pm["testkey"] = "before"
        mock = Mock()
        sub = pm.wire(mock.method)
        pm["testkey"] = "between"
        mock.method.assert_called_once_with({"testkey": "between"})

        mock.reset_mock()
        pm.unwire(sub)
        pm["testkey"] = "after"
        mock.method.assert_not_called()
Beispiel #4
0
 def testDeletionInGeneralWiring(self):
     pm = PropertyLayer(testkey="somevalue")
     mock = Mock()
     pm.wire(mock.method)
     del pm["testkey"]
     mock.method.assert_called_once_with({"testkey": PropertyDeleted})