def testEventPreventedWhenValueUnchanged(self): pm = PropertyLayer() pm["testkey"] = "testvalue" mock = Mock() pm.wire(mock.method) pm["testkey"] = "testvalue" mock.method.assert_not_called()
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"})
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()
def testDeletionInGeneralWiring(self): pm = PropertyLayer(testkey="somevalue") mock = Mock() pm.wire(mock.method) del pm["testkey"] mock.method.assert_called_once_with({"testkey": PropertyDeleted})