implement property deletion handling; activate scheduler deletion

This commit is contained in:
Jakob Ketterl
2021-02-26 01:12:03 +01:00
parent 91c4d6f568
commit 412e0a51c7
8 changed files with 102 additions and 25 deletions

View File

@ -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()