Commit 96b7d8af authored by Shelepnev Dmitry's avatar Shelepnev Dmitry
Browse files

Write tests for OpenSearch and SerachTerms

parent 0403a420
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -227,8 +227,8 @@ class SearchBooksFeed(Feed):
            # TODO: Переделать на поиск авторов
            books = Book.objects.filter(authors__last_name__contains=searchterms)
        elif searchtype == 'genres':
            # TODO: Переделать на поиск жанров
            books = Book.objects.filter(genres__section__contains=searchterms)
            # TODO: Переделать на поиск жанров (genre нужно заменить на section нужно скорее всего)
            books = Book.objects.filter(genres__genre__contains=searchterms)
        else:
            books = Book.objects.filter(title__contains=searchterms)

+18 −3
Original line number Diff line number Diff line
@@ -48,10 +48,25 @@ class ModelsTestCase(TestCase):
        self.assertEquals(response.status_code, 200)
        self.assertIn('www.sopds.ru', response.content.decode())
        
    def test_SearchTypes(self):
    def test_SearchTerms(self):
        c = Client()
        response = c.get('/opds/search/')
        response = c.get('/opds/search/Драк/')
        self.assertEquals(response.status_code, 200)
        self.assertIn('www.sopds.ru', response.content.decode())
        self.assertIn(_("Search by titles"), response.content.decode())
        
        response = c.get('/opds/search/titles/Драк/')
        self.assertEquals(response.status_code, 200)
        self.assertIn("Драконьи Услуги", response.content.decode())
        self.assertIn("Куприянов Денис", response.content.decode())
        
        response = c.get('/opds/search/authors/Логинов/')
        self.assertEquals(response.status_code, 200)
        self.assertIn("Любовь в жизни Обломова", response.content.decode())
        self.assertIn("Логинов Святослав", response.content.decode())     
        
        response = c.get('/opds/search/genres/antiq/')
        self.assertEquals(response.status_code, 200)
        self.assertIn("The Sanctuary Sparrow", response.content.decode())
        self.assertIn("Peters Ellis", response.content.decode())    
        
          
 No newline at end of file