def test_within(self): """Test the `within()` method.""" expected = {'$within': {'$box': [[1, 2], [3, 4]]}} actual = geo.within('box', [1, 2], [3, 4]) self.assertEqual(actual, expected) expected = {'$within': {'$polygon': {'a': {'x': 1, 'y': 2}, 'b': {'x': 3, 'y': 4}}}} actual = geo.within('polygon', a={'x': 1, 'y': 2}, b={'x': 3, 'y': 4}) self.assertEqual(actual, expected)
def test_within(self): """Test the `within()` method.""" expected = {'$within': {'$box': [[1, 2], [3, 4]]}} actual = geo.within('box', [1, 2], [3, 4]) self.assertEqual(actual, expected) expected = { '$within': { '$polygon': { 'a': { 'x': 1, 'y': 2 }, 'b': { 'x': 3, 'y': 4 } } } } actual = geo.within('polygon', a={'x': 1, 'y': 2}, b={'x': 3, 'y': 4}) self.assertEqual(actual, expected)
def test_within_runtimeerror(self): """Test that `within()` raises `RuntimeError`.""" with self.assertRaises(RuntimeError): geo.within('shape', *[1, 2], **{'a': {'x': 3, 'y': 4}})