示例#1
0
 def test_expression_failure_string(self):
     """Validation: test when string value does not meet the expression."""
     from natcap.invest import validation
     error_msg = validation.check_number("35", 'int(value) < 0')
     self.assertTrue('does not meet condition' in error_msg)
示例#2
0
 def test_expression_failure(self):
     """Validation: test when a number does not meet the expression."""
     from natcap.invest import validation
     error_msg = validation.check_number(35, 'float(value) < 0')
     self.assertTrue('does not meet condition' in error_msg)
示例#3
0
 def test_expression(self):
     """Validation: test that we can use numeric expressions."""
     from natcap.invest import validation
     self.assertEqual(
         None, validation.check_number(35, '(value < 100) & (value > 4)'))
示例#4
0
 def test_expression_missing_value(self):
     """Validation: test the expression string for the 'value' term."""
     from natcap.invest import validation
     with self.assertRaises(AssertionError):
         error_msg = validation.check_number(35, 'foo < 5')
示例#5
0
 def test_string(self):
     """Validation: test when a string is not a number."""
     from natcap.invest import validation
     error_msg = validation.check_number('this is a string')
     self.assertTrue('could not be interpreted as a number' in error_msg)