예제 #1
0
파일: test_geo.py 프로젝트: dirn/Simon
    def test_polygon_valueerror(self):
        """Test that `polygon()` raises `ValueError`."""

        with self.assertRaises(ValueError):
            geo.polygon([1, 2], [3])

        with self.assertRaises(ValueError):
            geo.polygon([1, 2], [3, 4, 5])
예제 #2
0
    def test_polygon_valueerror(self):
        """Test that `polygon()` raises `ValueError`."""

        with self.assertRaises(ValueError):
            geo.polygon([1, 2], [3])

        with self.assertRaises(ValueError):
            geo.polygon([1, 2], [3, 4, 5])
예제 #3
0
파일: test_geo.py 프로젝트: dirn/Simon
    def test_polygon_typeerror(self):
        """Test that `polygon()` raises `TypeError`."""

        with self.assertRaises(TypeError):
            geo.polygon()

        with self.assertRaises(TypeError):
            geo.polygon(1)

        with self.assertRaises(TypeError):
            geo.polygon([1])

        with self.assertRaises(TypeError):
            geo.polygon([1, 2, 3])

        with self.assertRaises(TypeError):
            geo.polygon([1, 2], 3)
예제 #4
0
    def test_polygon_typeerror(self):
        """Test that `polygon()` raises `TypeError`."""

        with self.assertRaises(TypeError):
            geo.polygon()

        with self.assertRaises(TypeError):
            geo.polygon(1)

        with self.assertRaises(TypeError):
            geo.polygon([1])

        with self.assertRaises(TypeError):
            geo.polygon([1, 2, 3])

        with self.assertRaises(TypeError):
            geo.polygon([1, 2], 3)
예제 #5
0
파일: test_geo.py 프로젝트: dirn/Simon
    def test_polygon_mappings_valueerror(self):
        """Test that `polygon()` raises `ValueError` with mappings."""

        with self.assertRaises(ValueError):
            geo.polygon({'a': 1})

        with self.assertRaises(ValueError):
            geo.polygon({'a': {'b': 1}})

        with self.assertRaises(ValueError):
            geo.polygon({'a': {'b': 1, 'c': 2}})

        with self.assertRaises(ValueError):
            geo.polygon({'a': {'b': 1, 'c': 2}, 'd': {'e': 3}})
예제 #6
0
    def test_polygon_mappings_valueerror(self):
        """Test that `polygon()` raises `ValueError` with mappings."""

        with self.assertRaises(ValueError):
            geo.polygon({'a': 1})

        with self.assertRaises(ValueError):
            geo.polygon({'a': {'b': 1}})

        with self.assertRaises(ValueError):
            geo.polygon({'a': {'b': 1, 'c': 2}})

        with self.assertRaises(ValueError):
            geo.polygon({'a': {'b': 1, 'c': 2}, 'd': {'e': 3}})
예제 #7
0
파일: test_geo.py 프로젝트: dirn/Simon
    def test_polygon(self):
        """Test the `polygon()` method."""

        with mock.patch('simon.geo.within') as within:
            geo.polygon([1, 2], [3, 4], [5, 6])
            within.assert_called_with('polygon', [1, 2], [3, 4], [5, 6])

            geo.polygon({'a': {'x': 1, 'y': 2}, 'b': {'x': 3, 'y': 4}})
            within.assert_called_with('polygon', a={'x': 1, 'y': 2},
                                      b={'x': 3, 'y': 4})

        expected = {'$within': {'$polygon': [[1, 2], [3, 4], [5, 6]]}}
        actual = geo.polygon([1, 2], [3, 4], [5, 6])
        self.assertEqual(actual, expected)

        expected = {'$within': {'$polygon': {'a': {'x': 1, 'y': 2},
                                             'b': {'x': 3, 'y': 4}}}}
        actual = geo.polygon({'a': {'x': 1, 'y': 2}, 'b': {'x': 3, 'y': 4}})
        self.assertEqual(actual, expected)
예제 #8
0
    def test_polygon(self):
        """Test the `polygon()` method."""

        with mock.patch('simon.geo.within') as within:
            geo.polygon([1, 2], [3, 4], [5, 6])
            within.assert_called_with('polygon', [1, 2], [3, 4], [5, 6])

            geo.polygon({'a': {'x': 1, 'y': 2}, 'b': {'x': 3, 'y': 4}})
            within.assert_called_with('polygon',
                                      a={
                                          'x': 1,
                                          'y': 2
                                      },
                                      b={
                                          'x': 3,
                                          'y': 4
                                      })

        expected = {'$within': {'$polygon': [[1, 2], [3, 4], [5, 6]]}}
        actual = geo.polygon([1, 2], [3, 4], [5, 6])
        self.assertEqual(actual, expected)

        expected = {
            '$within': {
                '$polygon': {
                    'a': {
                        'x': 1,
                        'y': 2
                    },
                    'b': {
                        'x': 3,
                        'y': 4
                    }
                }
            }
        }
        actual = geo.polygon({'a': {'x': 1, 'y': 2}, 'b': {'x': 3, 'y': 4}})
        self.assertEqual(actual, expected)
예제 #9
0
파일: test_geo.py 프로젝트: dirn/Simon
    def test_polygon_mappings_typeerror(self):
        """Test that `polygon()` raises `TypeError` with mappings."""

        with self.assertRaises(TypeError):
            geo.polygon({'a': {'b': 1, 'c': 2}, 'd': 3})
예제 #10
0
    def test_polygon_mappings_typeerror(self):
        """Test that `polygon()` raises `TypeError` with mappings."""

        with self.assertRaises(TypeError):
            geo.polygon({'a': {'b': 1, 'c': 2}, 'd': 3})