Esempio n. 1
0
    def test_results_are_empty_when_none_in_range(self):
        locator = BasicLocator(self.shopLocations)
        radius = 1000

        searchResults = locator.Search(self.origin.Latitude + 5,
                                       self.origin.Longitude + 5, radius)

        self.assertEqual(len(searchResults), 0)
Esempio n. 2
0
    def test_results_are_not_empty(self):
        locator = BasicLocator(self.shopLocations)
        radius = 1000

        searchResults = locator.Search(self.origin.Latitude,
                                       self.origin.Longitude, radius)

        self.assertGreater(len(searchResults), 0)
Esempio n. 3
0
    def test_results_are_within_range(self):

        locator = BasicLocator(self.shopLocations)
        radius = 1000

        searchResults = locator.Search(self.origin.Latitude,
                                       self.origin.Longitude, radius)
        self.assertGreater(len(searchResults), 0)

        for item in searchResults:
            distance = CoordinateHelper.GetDistanceMeters(
                self.origin, item.Location)
            self.assertLessEqual(distance, radius)
Esempio n. 4
0
    def test_result_contains_known_location(self):
        locator = BasicLocator(self.shopLocations)
        radius = 10  #use a small radius to get as few as possible

        searchResults = locator.Search(self.origin.Latitude,
                                       self.origin.Longitude, radius)
        self.assertGreater(len(searchResults), 0)

        contains = False
        for item in searchResults:
            if (item.Location.Latitude
                    == self.origin.Latitude) and (item.Location.Longitude
                                                  == self.origin.Longitude):
                contains = True
                break

        self.assertTrue(contains)
Esempio n. 5
0
 def test_search_raises_when_negative_coordinates(self):
     locator = BasicLocator(self.shopLocations)
     radius = 1000
     #self.assertRaises(ValueError, locator.Search, -1000, -1000, radius)
     with self.assertRaises(ValueError):
         locator.Search(-1000, -1000, radius)
Esempio n. 6
0
    def test_search_raises_when_radius_negative(self):
        locator = BasicLocator(self.shopLocations)
        radius = -1

        with self.assertRaises(ValueError):
            locator.Search(self.origin.Latitude, self.origin.Longitude, radius)