예제 #1
0
 def testGetSearchResults(self):
     global search_results
     facade = SearchFacade(self.dmd)
     search_results = createResultsFromRange(25)
     results = facade.getSearchResults( "testquery", None )
     results = results['results']
     dummyIds = [result.id for result in results
                 if isinstance(result, DummyResult)]
     self.assertEquals( set(range(1,26)), set(dummyIds) )
예제 #2
0
 def testSortByExcerpt(self):
     ids = [6, 4, 3, 2, 8, 5, 9, 7, 1]
     global search_results
     search_results = createResultsFromIds(ids)
     facade = SearchFacade(self.dmd)
     results = facade.getSearchResults("testquery", category=None)
     results = results['results']
     resultIds = [result.id for result in results]
     self.assertEquals(range(1, 10), resultIds)
예제 #3
0
 def testSortByExcerpt(self):
     ids = [6,4,3,2,8,5,9,7,1]
     global search_results
     search_results = createResultsFromIds(ids)
     facade = SearchFacade(self.dmd)
     results = facade.getSearchResults( "testquery", category=None )
     results = results['results']
     resultIds = [result.id for result in results]
     self.assertEquals( range(1,10), resultIds )
예제 #4
0
 def testGetSearchResults(self):
     global search_results
     facade = SearchFacade(self.dmd)
     search_results = createResultsFromRange(25)
     results = facade.getSearchResults("testquery", None)
     results = results['results']
     dummyIds = [
         result.id for result in results if isinstance(result, DummyResult)
     ]
     self.assertEquals(set(range(1, 26)), set(dummyIds))
예제 #5
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) )
예제 #6
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) )
예제 #7
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))
예제 #8
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))
예제 #9
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) )
예제 #10
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))
예제 #11
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)
예제 #12
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 )