openwebrx-clone/test/property/validators/test_or_validator.py

18 lines
646 B
Python
Raw Permalink Normal View History

2021-01-24 20:58:02 +00:00
from unittest import TestCase
from owrx.property.validators import OrValidator, IntegerValidator, StringValidator
class OrValidatorTest(TestCase):
def testPassesAnyValidators(self):
validator = OrValidator(IntegerValidator(), StringValidator())
self.assertTrue(validator.isValid(42))
self.assertTrue(validator.isValid("text"))
def testRejectsOtherTypes(self):
validator = OrValidator(IntegerValidator(), StringValidator())
self.assertFalse(validator.isValid(.5))
def testRejectsIfNoValidator(self):
validator = OrValidator()
self.assertFalse(validator.isValid("any value"))