def test_box_valueerror(self): """Test that `box()` raises `ValueError`.""" with self.assertRaises(ValueError): geo.box([1, 2, 3], [4, 5]) with self.assertRaises(ValueError): geo.box([1, 2], [3, 4, 5])
def test_box_typeerror(self): """Test that `box()` raises `TypeError`.""" with self.assertRaises(TypeError): geo.box(1, [2, 3]) with self.assertRaises(TypeError): geo.box([1, 2], 3)
def test_box(self): """Test the `box()` method.""" with mock.patch('simon.geo.within') as within: geo.box([1, 2], [3, 4]) within.assert_called_with('box', [1, 2], [3, 4]) expected = {'$within': {'$box': [[1, 2], [3, 4]]}} actual = geo.box([1, 2], [3, 4]) self.assertEqual(actual, expected)