def testDeletionIsSent(self): pm = PropertyLayer(testkey="somevalue") mock = Mock() pm.wireProperty("testkey", mock.method) mock.method.reset_mock() del pm["testkey"] mock.method.assert_called_once_with(PropertyDeleted)
def testSubscribeBeforeSet(self): pm = PropertyLayer() mock = Mock() pm.wireProperty("testkey", mock.method) mock.method.assert_not_called() pm["testkey"] = "newvalue" mock.method.assert_called_once_with("newvalue")
def testNoDeletionEventWhenPropertyDoesntExist(self): pm = PropertyLayer(otherkey="somevalue") mock = Mock() pm.wireProperty("testkey", mock.method) mock.method.reset_mock() with self.assertRaises(KeyError): del pm["testkey"] mock.method.assert_not_called()