Exemplo n.º 1
0
    def test_near_valueerror(self):
        """Test that `near()` raises `ValueError`."""

        with self.assertRaises(ValueError):
            geo.near([1])

        with self.assertRaises(ValueError):
            geo.near([1, 2, 3])
Exemplo n.º 2
0
    def test_near_valueerror(self):
        """Test that `near()` raises `ValueError`."""

        with self.assertRaises(ValueError):
            geo.near([1])

        with self.assertRaises(ValueError):
            geo.near([1, 2, 3])
Exemplo n.º 3
0
    def test_near(self):
        """Test the `near()` method."""

        expected = {'$near': [1, 2]}
        actual = geo.near([1, 2])
        self.assertEqual(actual, expected)

        expected = {'$near': [1, 2], '$maxDistance': 3}
        actual = geo.near([1, 2], max_distance=3)
        self.assertEqual(actual, expected)

        expected = {'$near': [1, 2], '$uniqueDocs': True}
        actual = geo.near([1, 2], unique_docs=True)
        self.assertEqual(actual, expected)

        expected = {'$near': [1, 2], '$maxDistance': 3, '$uniqueDocs': True}
        actual = geo.near([1, 2], max_distance=3, unique_docs=True)
        self.assertEqual(actual, expected)

        # near() supports point as a tuple
        expected = {'$near': (1, 2)}
        actual = geo.near((1, 2))
        self.assertEqual(actual, expected)
Exemplo n.º 4
0
    def test_near(self):
        """Test the `near()` method."""

        expected = {'$near': [1, 2]}
        actual = geo.near([1, 2])
        self.assertEqual(actual, expected)

        expected = {'$near': [1, 2], '$maxDistance': 3}
        actual = geo.near([1, 2], max_distance=3)
        self.assertEqual(actual, expected)

        expected = {'$near': [1, 2], '$uniqueDocs': True}
        actual = geo.near([1, 2], unique_docs=True)
        self.assertEqual(actual, expected)

        expected = {'$near': [1, 2], '$maxDistance': 3, '$uniqueDocs': True}
        actual = geo.near([1, 2], max_distance=3, unique_docs=True)
        self.assertEqual(actual, expected)

        # near() supports point as a tuple
        expected = {'$near': (1, 2)}
        actual = geo.near((1, 2))
        self.assertEqual(actual, expected)
Exemplo n.º 5
0
    def test_near_typeerror(self):
        """Test that `near()` raises `TypeError`."""

        with self.assertRaises(TypeError):
            geo.near(1)
Exemplo n.º 6
0
    def test_near_typeerror(self):
        """Test that `near()` raises `TypeError`."""

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