Exemple #1
0
    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)
Exemple #2
0
    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)
Exemple #3
0
    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)
Exemple #4
0
    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)
Exemple #5
0
    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)
Exemple #6
0
    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)
Exemple #7
0
    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)
Exemple #8
0
    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)
Exemple #9
0
    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)
Exemple #10
0
    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))
Exemple #11
0
    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))
Exemple #12
0
    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)