create filtering that prevents overwriting the device name

This commit is contained in:
Jakob Ketterl
2021-02-24 00:09:57 +01:00
parent 4199a583f8
commit f69d78926e
8 changed files with 99 additions and 25 deletions

View File

View File

@ -0,0 +1,17 @@
from owrx.property.filter import ByLambda
from unittest import TestCase
from unittest.mock import Mock
class TestByLambda(TestCase):
def testPositive(self):
mock = Mock(return_value=True)
filter = ByLambda(mock)
self.assertTrue(filter.apply("test_key"))
mock.assert_called_with("test_key")
def testNegateive(self):
mock = Mock(return_value=False)
filter = ByLambda(mock)
self.assertFalse(filter.apply("test_key"))
mock.assert_called_with("test_key")

View File

@ -0,0 +1,12 @@
from owrx.property.filter import ByPropertyName
from unittest import TestCase
class ByPropertyNameTest(TestCase):
def testNameIsInList(self):
filter = ByPropertyName("test_key")
self.assertTrue(filter.apply("test_key"))
def testNameNotInList(self):
filter = ByPropertyName("test_key")
self.assertFalse(filter.apply("other_key"))