implement property deletion handling; activate scheduler deletion
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
from owrx.property import PropertyLayer
|
||||
from owrx.property import PropertyLayer, PropertyDeleted
|
||||
from unittest import TestCase
|
||||
from unittest.mock import Mock
|
||||
|
||||
@ -67,3 +67,27 @@ class PropertyLayerTest(TestCase):
|
||||
pm.wire(mock.method)
|
||||
pm["testkey"] = "testvalue"
|
||||
mock.method.assert_not_called()
|
||||
|
||||
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 testDeletionInGeneralWiring(self):
|
||||
pm = PropertyLayer(testkey="somevalue")
|
||||
mock = Mock()
|
||||
pm.wire(mock.method)
|
||||
del pm["testkey"]
|
||||
mock.method.assert_called_once_with({"testkey": PropertyDeleted})
|
||||
|
||||
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()
|
||||
|
Reference in New Issue
Block a user