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,6 +1,6 @@
from unittest import TestCase
from unittest.mock import Mock
from owrx.property import PropertyLayer, PropertyStack
from owrx.property import PropertyLayer, PropertyStack, PropertyDeleted
class PropertyStackTest(TestCase):
@ -135,7 +135,7 @@ class PropertyStackTest(TestCase):
mock.method.assert_called_once_with("unique value")
mock.reset_mock()
stack.removeLayer(high_layer)
mock.method.assert_called_once_with(None)
mock.method.assert_called_once_with(PropertyDeleted)
def testReplaceLayer(self):
first_layer = PropertyLayer()
@ -162,7 +162,7 @@ class PropertyStackTest(TestCase):
mock = Mock()
stack.wire(mock.method)
stack.removeLayer(layer)
mock.method.assert_called_once_with({"testkey": None})
mock.method.assert_called_once_with({"testkey": PropertyDeleted})
mock.reset_mock()
layer["testkey"] = "after"
@ -195,3 +195,23 @@ class PropertyStackTest(TestCase):
om.addLayer(0, high_pm)
om["testkey"] = "new value"
self.assertEqual(low_pm["testkey"], "new value")
def testDeletionEvent(self):
ps = PropertyStack()
pm = PropertyLayer(testkey="testvalue")
ps.addLayer(0, pm)
mock = Mock()
ps.wire(mock.method)
del ps["testkey"]
mock.method.assert_called_once_with({"testkey": PropertyDeleted})
def testDeletionWithSecondLayer(self):
ps = PropertyStack()
low_pm = PropertyLayer(testkey="testvalue")
high_pm = PropertyLayer()
ps.addLayer(0, high_pm)
ps.addLayer(1, low_pm)
mock = Mock()
ps.wire(mock.method)
del low_pm["testkey"]
mock.method.assert_called_once_with({"testkey": PropertyDeleted})