From b3a5a36d9c9504cef66a911f995734225a53bf0f Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Sun, 22 Mar 2020 19:42:59 +0100 Subject: [PATCH] more tests --- test/property/test_property.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/test/property/test_property.py b/test/property/test_property.py index 1529f8c..26634c9 100644 --- a/test/property/test_property.py +++ b/test/property/test_property.py @@ -1,8 +1,28 @@ import unittest +from unittest.mock import Mock from owrx.property import Property class PropertyTest(unittest.TestCase): - def testSimple(self): + def testValue(self): prop = Property("testvalue") self.assertEqual(prop.getValue(), "testvalue") + + def testChangeValue(self): + prop = Property("before") + prop.setValue("after") + self.assertEqual(prop.getValue(), "after") + + def testInitialValueOnCallback(self): + prop = Property("before") + m = Mock() + prop.wire(m.method) + m.method.assert_called_once_with("before") + + def testChangedValueOnCallback(self): + prop = Property("before") + m = Mock() + prop.wire(m.method) + m.reset_mock() + prop.setValue("after") + m.method.assert_called_with("after")