示例#1
0
 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)
示例#2
0
 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))
示例#3
0
 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))
示例#4
0
 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)
示例#5
0
 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)
示例#6
0
 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)