Ejemplo n.º 1
0
    def test_search_returns_empty_when_maximumItemCount_is_zero(self):
        #Todo: use mocking for supplying objects
        basicLocator = BasicLocator(self.shopLocations)
        geohashLocator = GeohashLocator(self.shopLocations)
        locator = HybridLocator(geohashLocator, basicLocator)
        provider = SearchProvider(locator)
        radius = 1000

        searchResults = provider.Search(self.origin.Latitude,
                                        self.origin.Longitude, radius, None, 0)

        resultCount = len(searchResults)
        self.assertEqual(resultCount, 0)
Ejemplo n.º 2
0
    def test_search_returns_results_when_tags_null(self):
        #Todo: use mocking for supplying objects
        basicLocator = BasicLocator(self.shopLocations)
        geohashLocator = GeohashLocator(self.shopLocations)
        locator = HybridLocator(geohashLocator, basicLocator)
        provider = SearchProvider(locator)
        radius = 1000

        searchResults = provider.Search(self.origin.Latitude,
                                        self.origin.Longitude, radius, None,
                                        10)

        resultCount = len(searchResults)
        self.assertGreater(resultCount, 0)
Ejemplo n.º 3
0
    def test_search_returns_requested_count_of_results(self):
        #Todo: use mocking for supplying objects
        basicLocator = BasicLocator(self.shopLocations)
        geohashLocator = GeohashLocator(self.shopLocations)
        locator = HybridLocator(geohashLocator, basicLocator)
        provider = SearchProvider(locator)
        radius = 1000

        count = 5
        searchResults = provider.Search(self.origin.Latitude,
                                        self.origin.Longitude, radius, None,
                                        count)

        resultCount = len(searchResults)
        self.assertEqual(resultCount, count)
Ejemplo n.º 4
0
    def test_search_returns_empty_when_no_matching_tags(self):
        #Todo: use mocking for supplying objects
        basicLocator = BasicLocator(self.shopLocations)
        geohashLocator = GeohashLocator(self.shopLocations)
        locator = HybridLocator(geohashLocator, basicLocator)
        provider = SearchProvider(locator)
        radius = 1000

        tags = ["---"]
        searchResults = provider.Search(self.origin.Latitude,
                                        self.origin.Longitude, radius,
                                        set(tags), 10)

        resultCount = len(searchResults)
        self.assertEqual(resultCount, 0)
Ejemplo n.º 5
0
    def test_search_returns_all_elements_when_requested_count_is_more_than_element_count(
            self):
        #Todo: use mocking for supplying objects
        basicLocator = BasicLocator(self.shopLocations)
        geohashLocator = GeohashLocator(self.shopLocations)
        locator = HybridLocator(geohashLocator, basicLocator)
        provider = SearchProvider(locator)
        radius = 5000

        count = 50000
        searchResults = provider.Search(self.origin.Latitude,
                                        self.origin.Longitude, radius, None,
                                        count)

        totalCount = len(self.shopLocations)
        resultCount = len(searchResults)
        self.assertEqual(resultCount, totalCount)
Ejemplo n.º 6
0
    def test_search_returns_only_results_with_specified_tags(self):
        #Todo: use mocking for supplying objects
        basicLocator = BasicLocator(self.shopLocations)
        geohashLocator = GeohashLocator(self.shopLocations)
        locator = HybridLocator(geohashLocator, basicLocator)
        provider = SearchProvider(locator)
        radius = 1000

        tags = ["tag1", "---"]
        searchResults = provider.Search(self.origin.Latitude,
                                        self.origin.Longitude, radius,
                                        set(tags), 10)

        resultCount = len(searchResults)
        self.assertGreater(resultCount, 0)

        for element in searchResults:
            self.assertTrue(tags[0] in element.Shop.tags)