Example #1
0
 def test_string_boolean(self):
     """Validation: an error should be raised when the type is wrong."""
     from natcap.invest import validation
     for non_boolean_value in ('true', 1, [], set()):
         self.assertTrue(
             isinstance(validation.check_boolean(non_boolean_value), str))
Example #2
0
 def test_invalid_string(self):
     """Validation: test when invalid strings are passed."""
     from natcap.invest import validation
     error_msg = validation.check_boolean('not clear')
     self.assertTrue(isinstance(error_msg, str))
     self.assertTrue('must be either True or False' in error_msg)
Example #3
0
 def test_actual_bool(self):
     """Validation: test when boolean type objects are passed."""
     from natcap.invest import validation
     self.assertEqual(None, validation.check_boolean(True))
     self.assertEqual(None, validation.check_boolean(False))