Ejemplo n.º 1
0
 def testCategoryCountFilter(self):
     global search_results
     search_results = createResultsFromRange(8,'cat1')
     search_results.extend( createResultsFromRange(7,'cat2') )
     facade = SearchFacade(self.dmd)
     sorter = DefaultSearchResultSorter( 20, 5 )
     results = facade.getQuickSearchResults( "testquery", sorter )
     results = results['results']
     cat1Ids = [result.id for result in results if result.category == 'cat1']
     self.assertEquals( set(range(1,6)), set(cat1Ids) )
Ejemplo n.º 2
0
 def testGetQuickSearchResults(self):
     global search_results
     facade = SearchFacade(self.dmd)
     search_results = createResultsFromRange(20)
     sorter = DefaultSearchResultSorter(10)
     results = facade.getQuickSearchResults( "testquery", sorter )
     results = results['results']
     # Should only have 10 results
     dummyIds = [result.id for result in results
                 if isinstance(result, DummyResult)]
     self.assertEquals( set(range(1,11)), set(dummyIds) )
Ejemplo n.º 3
0
 def testGetQuickSearchResults(self):
     global search_results
     facade = SearchFacade(self.dmd)
     search_results = createResultsFromRange(20)
     sorter = DefaultSearchResultSorter(10)
     results = facade.getQuickSearchResults("testquery", sorter)
     results = results['results']
     # Should only have 10 results
     dummyIds = [
         result.id for result in results if isinstance(result, DummyResult)
     ]
     self.assertEquals(set(range(1, 11)), set(dummyIds))
Ejemplo n.º 4
0
 def testCategoryCountFilter(self):
     global search_results
     search_results = createResultsFromRange(8, 'cat1')
     search_results.extend(createResultsFromRange(7, 'cat2'))
     facade = SearchFacade(self.dmd)
     sorter = DefaultSearchResultSorter(20, 5)
     results = facade.getQuickSearchResults("testquery", sorter)
     results = results['results']
     cat1Ids = [
         result.id for result in results if result.category == 'cat1'
     ]
     self.assertEquals(set(range(1, 6)), set(cat1Ids))
Ejemplo n.º 5
0
 def testCategorySortAndLimit2(self):
     global search_results
     maxPerCategory = 4
     device_results = createResultsFromRange(2 * maxPerCategory, 'Device')
     event_results = createResultsFromRange(2 * maxPerCategory, 'Event')
     other1_results = createResultsFromRange(2 * maxPerCategory, 'Category1')
     other2_results = createResultsFromRange(2 * maxPerCategory, 'Category2')
     search_results = other2_results + event_results + device_results + \
                      other1_results
     facade = SearchFacade(self.dmd)
     sorter = DefaultSearchResultSorter( 2 * maxPerCategory, maxPerCategory )
     results = facade.getQuickSearchResults( 'testquery',
                                             sorter )
     results = results['results']
     expected = device_results[:maxPerCategory] + \
                event_results[:maxPerCategory]
     self.assertEquals( expected, list(results) )
Ejemplo n.º 6
0
 def testCategorySortAndLimit2(self):
     global search_results
     maxPerCategory = 4
     device_results = createResultsFromRange(2 * maxPerCategory, 'Device')
     event_results = createResultsFromRange(2 * maxPerCategory, 'Event')
     other1_results = createResultsFromRange(2 * maxPerCategory,
                                             'Category1')
     other2_results = createResultsFromRange(2 * maxPerCategory,
                                             'Category2')
     search_results = other2_results + event_results + device_results + \
                      other1_results
     facade = SearchFacade(self.dmd)
     sorter = DefaultSearchResultSorter(2 * maxPerCategory, maxPerCategory)
     results = facade.getQuickSearchResults('testquery', sorter)
     results = results['results']
     expected = device_results[:maxPerCategory] + \
                event_results[:maxPerCategory]
     self.assertEquals(expected, list(results))
Ejemplo n.º 7
0
    def testCategoryLimit(self):
        global search_results
        device_results = createResultsFromRange(9, 'Device')
        event_results = createResultsFromRange(9, 'Event')
        other1_results = createResultsFromRange(9, 'Category1')
        other2_results = createResultsFromRange(9, 'Category2')
        search_results = other2_results + event_results + device_results + \
                         other1_results
        facade = SearchFacade(self.dmd)
        maxPerCategory = 5
        sorter = DefaultSearchResultSorter(
            maxResultsPerCategory=maxPerCategory)
        results = facade.getQuickSearchResults('testquery', sorter)
        results = results['results']
        expected = device_results[:maxPerCategory] + \
                   event_results[:maxPerCategory] + \
                   other1_results[:maxPerCategory] + \
                   other2_results[:maxPerCategory]
        results = list(results)

        self.assertEqual(len(expected), len(results))
        self.assertEquals(expected, results)
Ejemplo n.º 8
0
    def testCategoryLimit(self):
        global search_results
        device_results = createResultsFromRange(9, 'Device')
        event_results = createResultsFromRange(9, 'Event')
        other1_results = createResultsFromRange(9, 'Category1')
        other2_results = createResultsFromRange(9, 'Category2')
        search_results = other2_results + event_results + device_results + \
                         other1_results
        facade = SearchFacade(self.dmd)
        maxPerCategory = 5
        sorter = DefaultSearchResultSorter( maxResultsPerCategory=maxPerCategory )
        results = facade.getQuickSearchResults( 'testquery',
                                                sorter )
        results = results['results']
        expected = device_results[:maxPerCategory] + \
                   event_results[:maxPerCategory] + \
                   other1_results[:maxPerCategory] + \
                   other2_results[:maxPerCategory]
        results = list(results)

        self.assertEqual(len(expected), len(results))
        self.assertEquals( expected, results )