def test_validate_point_alternate_type(self): """Test the `_validate_point()` method with alternate types.""" geo._validate_point({ 'a': 1, 'b': 2 }, alternate_type=collections.Mapping)
def test_validate_point_alternate_type_typeerror(self): ("Test that `_validate_point()` raises `TypeError` with " "alternate types.") with self.assertRaises(TypeError): geo._validate_point(1, alternate_type=str) with self.assertRaises(TypeError): geo._validate_point('a', alternate_type=int)
def test_validate_point_alternate_type_valueerror(self): ("Test that `_validate_point()` raises `ValueError` with " "alternate types.") with self.assertRaises(ValueError): geo._validate_point({'a': 1}, alternate_type=collections.Mapping) with self.assertRaises(ValueError): geo._validate_point({'a': 1, 'b': 2, 'c': 3}, alternate_type=collections.Mapping)
def test_validate_point_alternate_type_valueerror(self): ("Test that `_validate_point()` raises `ValueError` with " "alternate types.") with self.assertRaises(ValueError): geo._validate_point({'a': 1}, alternate_type=collections.Mapping) with self.assertRaises(ValueError): geo._validate_point({ 'a': 1, 'b': 2, 'c': 3 }, alternate_type=collections.Mapping)
def test_validate_point_name(self): """Test the `_validate_point()` method with names.""" with self.assertRaises(TypeError) as e: geo._validate_point(1, 'name') expected = 'name must be a list containing exactly 2 elements' actual = str(e.exception) self.assertEqual(actual, expected) with self.assertRaises(ValueError) as e: geo._validate_point([1], 'name') expected = 'name must be a list containing exactly 2 elements' actual = str(e.exception) self.assertEqual(actual, expected)
def test_validate_point_typeerror(self): """Test that `_validate_point()` raises `TypeError`.""" # Test with a string with self.assertRaises(TypeError) as e: geo._validate_point('a') expected = '`point` must be a list containing exactly 2 elements' actual = str(e.exception) self.assertEqual(actual, expected) # Test with an int with self.assertRaises(TypeError) as e: geo._validate_point(1) expected = '`point` must be a list containing exactly 2 elements' actual = str(e.exception) self.assertEqual(actual, expected)
def test_validate_point_valueerror(self): """Test the `_validate_point()` method.""" # Test with 1 element with self.assertRaises(ValueError) as e: geo._validate_point([1]) expected = '`point` must be a list containing exactly 2 elements' actual = str(e.exception) self.assertEqual(actual, expected) # Test with 3 elements with self.assertRaises(ValueError) as e: geo._validate_point([1, 2, 3]) expected = '`point` must be a list containing exactly 2 elements' actual = str(e.exception) self.assertEqual(actual, expected) # The following should not raise an exception geo._validate_point([1, 2]) geo._validate_point((1, 2))
def test_validate_point_alternate_type(self): """Test the `_validate_point()` method with alternate types.""" geo._validate_point({'a': 1, 'b': 2}, alternate_type=collections.Mapping)