openwebrx-clone/test/owrx/property/validators/test_number_validator.py
2022-12-12 16:06:15 +01:00

19 lines
702 B
Python

from unittest import TestCase
from owrx.property.validators import NumberValidator
class NumberValidatorTest(TestCase):
def testPassesNumbers(self):
validator = NumberValidator()
self.assertTrue(validator.isValid(123))
self.assertTrue(validator.isValid(-2))
self.assertTrue(validator.isValid(.5))
def testDoesntPassOthers(self):
validator = NumberValidator()
# bool is a subclass of int, so it passes this test.
# not sure if we need to be more specific or if this is alright.
# self.assertFalse(validator.isValid(True))
self.assertFalse(validator.isValid("text"))
self.assertFalse(validator.isValid(object()))