openwebrx-clone/test/property/validators/test_or_validator.py
2021-01-24 21:58:02 +01:00

18 lines
646 B
Python

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"))