Example #1
0
    def test_filtering(self):
        self.assertTrue(Video.objects.count())
        for video in Video.objects.all():
            video_changed_tasks.delay(video.pk)

        reset_solr()

        rpc = SearchApiClass()

        rdata = RpcMultiValueDict(dict(q=u' ', video_lang='en'))
        result = rpc.search(rdata, self.user, testing=True)['sqs']

        self.assertTrue(len(result))
        for video in VideoIndex.public():
            if video.video_language == 'en':
                self.assertTrue(
                    video.object in [item.object for item in result])

        rdata = RpcMultiValueDict(dict(q=u' ', langs='en'))
        result = rpc.search(rdata, self.user, testing=True)['sqs']

        self.assertTrue(len(result))
        for video in VideoIndex.public():
            if video.languages and 'en' in video.languages:
                self.assertTrue(
                    video.object in [item.object for item in result])
Example #2
0
    def test_empty_query(self):
        rpc = SearchApiClass()

        rdata = RpcMultiValueDict(dict(q=u''))
        rpc.search(rdata, self.user, testing=True)['sqs']

        rdata = RpcMultiValueDict(dict(q=u' '))
        rpc.search(rdata, self.user, testing=True)['sqs']
Example #3
0
    def test_empty_query(self):
        rpc = SearchApiClass()
        
        rdata = RpcMultiValueDict(dict(q=u''))
        rpc.search(rdata, self.user, testing=True)['sqs']

        rdata = RpcMultiValueDict(dict(q=u' '))
        rpc.search(rdata, self.user, testing=True)['sqs']
Example #4
0
    def test_query_clean(self):
        video = Video.objects.all()[0]
        video.title = u"Cher BBC and Dawn French's Lookalikes"
        video.save()
        reset_solr()
        rpc = SearchApiClass()

        rdata = RpcMultiValueDict(dict(q=u'?BBC'))
        result = rpc.search(rdata, self.user, testing=True)['sqs']
        self.assertTrue(len(result))
Example #5
0
 def test_query_clean(self):
     video = Video.objects.all()[0]
     video.title = u"Cher BBC and Dawn French's Lookalikes"
     video.save()
     reset_solr()
     rpc = SearchApiClass()
     
     rdata = RpcMultiValueDict(dict(q=u'?BBC'))
     result = rpc.search(rdata, self.user, testing=True)['sqs']
     self.assertTrue(len(result))        
Example #6
0
    def test_rpc(self):
        rpc = SearchApiClass()
        rdata = RpcMultiValueDict(dict(q=u'BBC'))

        for title in self.titles:
            video = Video.objects.all()[0]
            video.title = title
            video.save()
            reset_solr()

            result = rpc.search(rdata, self.user, testing=True)['sqs']
            self.assertTrue(video in [item.object for item in result], title)
Example #7
0
 def test_rpc(self):
     rpc = SearchApiClass()
     rdata = RpcMultiValueDict(dict(q=u'BBC'))
     
     for title in self.titles:
         video = Video.objects.all()[0]
         video.title = title
         video.save()
         reset_solr()
         
         result = rpc.search(rdata, self.user, testing=True)['sqs']
         self.assertTrue(video in [item.object for item in result], title)
Example #8
0
    def test_search_relevance(self):
        reset_solr()

        rpc = SearchApiClass()
        rdata = RpcMultiValueDict(dict(q=u'unique'))

        result = rpc.search(rdata, self.user, testing=True)['sqs']
        videos = [item.object for item in result]

        # by default, title is more important than description
        self.assertEquals(videos[0].title, u"This is my unique title")
        self.assertEquals(videos[1].title, u"Default")
        self.assertEquals(videos[1].description,
                          u"this is my unique description")

        rdata = RpcMultiValueDict(dict(q=u'unique', sort="total_views"))
        result = rpc.search(rdata, self.user, testing=True)['sqs']
        videos = [item.object for item in result]

        self.assertEquals(videos[0].title, u"Default")
        self.assertEquals(videos[1].title, u"This is my unique title")
Example #9
0
 def test_search_index_updating(self):
     reset_solr()
     rpc = SearchApiClass()
     
     for title in self.titles:
         rdata = RpcMultiValueDict(dict(q=title))
         video = Video.objects.all()[0]
         video.title = title
         video.save()
         video.update_search_index()
         
         result = rpc.search(rdata, self.user, testing=True)['sqs']
         self.assertTrue(video in [item.object for item in result], title)
Example #10
0
 def test_filtering(self):
     self.assertTrue(Video.objects.count())
     for video in Video.objects.all():
         video_changed_tasks.delay(video.pk)
     
     reset_solr()
     
     rpc = SearchApiClass()
     
     rdata = RpcMultiValueDict(dict(q=u' ', video_lang='en'))
     result = rpc.search(rdata, self.user, testing=True)['sqs']
     
     self.assertTrue(len(result))
     for video in SearchQuerySet().models(Video):
         if video.video_language == 'en':
             self.assertTrue(video.object in [item.object for item in result])
     
     rdata = RpcMultiValueDict(dict(q=u' ', langs='en'))
     result = rpc.search(rdata, self.user, testing=True)['sqs']
     
     self.assertTrue(len(result))
     for video in SearchQuerySet().models(Video):
         if video.languages and 'en' in video.languages:
             self.assertTrue(video.object in [item.object for item in result])