openwebrx-clone/test/property/test_property_readonly.py
2021-01-30 16:03:35 +01:00

16 lines
577 B
Python

from unittest import TestCase
from owrx.property import PropertyLayer, PropertyReadOnly, PropertyWriteError
class PropertyReadOnlyTest(TestCase):
def testPreventsWrites(self):
layer = PropertyLayer()
layer["testkey"] = "initial value"
ro = PropertyReadOnly(layer)
with self.assertRaises(PropertyWriteError):
ro["testkey"] = "new value"
with self.assertRaises(PropertyWriteError):
ro["otherkey"] = "testvalue"
self.assertEqual(ro["testkey"], "initial value")
self.assertNotIn("otherkey", ro)