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