def test_find_campers_around_nomatch(self): camper1 = {"id": 1, "latitude": 1.0, "longitude": 1.0} camper2 = {"id": 1, "latitude": -1.0, "longitude": -1.0} data = {"campers": [camper1, camper2]} DataStoreAccess.populate_campers(self.ds, data) results = DataStoreAccess.find_campers_around(self.ds, Point(0.0, 0.0)) self.assertListEqual(results, []) results = DataStoreAccess.find_campers_around(self.ds, Point(1.0, 0.0)) self.assertListEqual(results, []) results = DataStoreAccess.find_campers_around(self.ds, Point(0.0, 1.0)) self.assertListEqual(results, [])
def test_find_campers_around_match(self): camper1 = {"id": 1, "latitude": 1.0, "longitude": 1.0} camper2 = {"id": 2, "latitude": -1.0, "longitude": -1.0} data = {"campers": [camper1, camper2]} DataStoreAccess.populate_campers(self.ds, data) results = DataStoreAccess.find_campers_around(self.ds, Point(1.0, 1.0)) self.assertListEqual([Camper(**camper1)], results) results = DataStoreAccess.find_campers_around(self.ds, Point(1.09, 1.09)) self.assertListEqual([Camper(**camper1)], results) results = DataStoreAccess.find_campers_around(self.ds, Point(0.91, 0.91)) self.assertListEqual([Camper(**camper1)], results) results = DataStoreAccess.find_campers_around(self.ds, Point(1.09, 0.91)) self.assertListEqual([Camper(**camper1)], results) results = DataStoreAccess.find_campers_around(self.ds, Point(0.91, 1.09)) self.assertListEqual([Camper(**camper1)], results) results = DataStoreAccess.find_campers_around(self.ds, Point(-1.0, -1.0)) self.assertListEqual([Camper(**camper2)], results) results = DataStoreAccess.find_campers_around(self.ds, Point(-1.09, -0.91)) self.assertListEqual([Camper(**camper2)], results)
def test_find_campers_around_match(self): data = {"campers": [self.camper1, self.camper2]} DataStoreAccess.populate_campers(self.ds, data) pos_points = [ Point(1.0, 1.0), Point(1.1, 1.1), Point(0.9, 0.9), Point(1.1, 0.9), Point(0.9, 1.1), ] expected_res = [Camper(**self.camper1)] for p in pos_points: results = DataStoreAccess.find_campers_around(self.ds, p) self.assertListEqual(results, expected_res, f"failed for {p}") neg_points = [Point(-1.0, -1.0), Point(-1.1, -0.9)] expected_res = [Camper(**self.camper2)] for p in neg_points: results = DataStoreAccess.find_campers_around(self.ds, p) self.assertListEqual(results, expected_res, f"failed for {p}")
def test_find_campers_around_nomatch(self): data = {"campers": [self.camper1, self.camper2]} DataStoreAccess.populate_campers(self.ds, data) nomatch_points = [ Point(0.0, 0.0), Point(1.0, 0.0), Point(0.0, 1.0), ] expected_res = [] for p in nomatch_points: results = DataStoreAccess.find_campers_around(self.ds, p) self.assertListEqual(results, expected_res, f"failed for {p}")