def test_validate_int_logging_none(self): ''' Test validate_int ''' logger = MockLogger() self.assertFalse(utils.validate_int(None, 0, 100, logger, "testname")) self.assertEqual("testname value is not set", logger.last_msg)
def test_validate_int_invalid(self): ''' Test validate_int ''' self.assertFalse(utils.validate_int(None, 0, 100)) self.assertFalse(utils.validate_int("A", 0, 100))
def test_validate_int(self): ''' Test validate_int ''' for value, min_value, max_value, expected in VALIDATE_INT_TESTS: self.assertEqual(expected, utils.validate_int(value, min_value, max_value))
def test_validate_int_logging_invalid(self): ''' Test validate_int ''' logger = MockLogger() self.assertFalse(utils.validate_int("A", 0, 100, logger, "testname")) self.assertEqual("testname value (A) is not an integer", logger.last_msg)
def test_validate_int_logging_too_high(self): ''' Test validate_int ''' logger = MockLogger() self.assertFalse(utils.validate_int(101, 0, 100, logger, "testname")) self.assertEqual("testname value 101 is greater than maximum (100)", logger.last_msg)
def test_validate_int_logging_too_low(self): ''' Test validate_int ''' logger = MockLogger() self.assertFalse(utils.validate_int(-1, 0, 100, logger, "testname")) self.assertEqual("testname value -1 is less than minimum (0)", logger.last_msg)