'Make sure the "within_distance" operator works.'

def test_within_distance(self):

    (event1, event2, event3) = self._create_event_data()
    point_and_distance = [[(-87.67892), 41.9120459], 5]
    events = self.Event.objects(location__within_distance=point_and_distance)
    self.assertEqual(events.count(), 2)
    events = list(events)
    self.assertTrue((event2 not in events))
    self.assertTrue((event1 in events))
    self.assertTrue((event3 in events))
    point_and_distance = [[(-122.415579), 37.7566023], 10]
    events = self.Event.objects(location__within_distance=point_and_distance)
    self.assertEqual(events.count(), 1)
    self.assertEqual(events[0], event2)
    point_and_distance = [[(-73.9509714), 40.7237134], 1]
    events = self.Event.objects(location__within_distance=point_and_distance)
    self.assertEqual(events.count(), 0)
    point_and_distance = [[(-87.67892), 41.9120459], 10]
    events = self.Event.objects(location__within_distance=point_and_distance)
    events = events.order_by('-date')
    self.assertEqual(events.count(), 2)
    self.assertEqual(events[0], event3)
