def test_default_filter_lookup(self): """Test default filter lookup. Example: http://localhost:8000/search/books-default-filter-lookup/ ?authors=Robin&authors=Luc """ # Create two authors author_1 = factories.AuthorFactory(name='Author1') author_2 = factories.AuthorFactory(name='Author2') authors = [author_1, author_2] # Add them to 3 books self.published[0].authors.add(*authors) self.published[1].authors.add(*authors) self.published[2].authors.add(*authors) # Update the Elasticsearch index call_command('search_index', '--rebuild', '-f') # Test self._field_filter_multiple_values( self.books_default_filter_lookup_url, 'authors', authors, 3 )
def setUpClass(cls): """Set up class.""" cls.publishers = [] cls.publishers.append( factories.PublisherFactory( name='Addison–Wesley', city='Brighton & Hove', state_province='East Midlands', country='Armenia', )) cls.publishers.append( factories.PublisherFactory( name='Adis International', city='Bristol', state_province='East of England', country='Argentina', )) cls.publishers.append( factories.PublisherFactory( name='Atlantic Books', city='Cardiff', state_province='North East', country='Belgium', )) cls.publishers.append( factories.PublisherFactory( name='Atlas Press', city='Carlisle', state_province='North West', country='Belarus', )) cls.publishers.append( factories.PublisherFactory( name='Book League of America', city='Chelmsford', state_province='South East', country='Burkina Faso', )) cls.publishers.append( factories.PublisherFactory( name='Book Works', city='Chester', state_province='South West', country='Burundi', )) cls.publishers.append( factories.PublisherFactory( name='Booktrope', city='Chichester', state_province='West Midlands', country='Netherlands', )) cls.publishers_url = reverse('publisherdocument-suggest', kwargs={}) cls.books = [] cls.books.append( factories.BookFactory( title='Aaaaa Bbbb', summary='`Twas brillig, and the slithy toves ' 'Did gyre and gimble in the wabe. ' 'All mimsy were the borogoves ' 'And the mome raths outgrabe.', publisher__name='Antares', publisher__country='Armenia', )) cls.books.append( factories.BookFactory( title='Aaaaa Cccc', summary='"Beware the Jabberwock, my son! ' 'The jaws that bite, the claws that catch! ' 'Beware the Jubjub bird, and shun ' 'The frumious Bandersnatch!', publisher__name='Antares', publisher__country='Armenia', )) cls.books.append( factories.BookFactory( title='Aaaaa Dddd', summary='He took his vorpal sword in his hand,' 'Long time the manxome foe he sought --' 'So rested he by the Tumtum tree,' 'And stood awhile in thought.', publisher__name='Antares', publisher__country='Armenia', )) cls.books += factories.BookFactory.create_batch( 10, publisher__name='Oxford University Press', publisher__city='Yerevan', publisher__state_province='Ararat', publisher__country='Ireland', ) cls.books_url = reverse('bookdocument-suggest', kwargs={}) cls.authors = [] cls.authors.append( factories.AuthorFactory( name='John Doe', salutation='Aaa Bbb', )) cls.authors.append( factories.AuthorFactory( name='Jane Doe', salutation='Aaa Ccc', )) cls.authors.append( factories.AuthorFactory( name='Armen Doe', salutation='Bbb Ccc', )) cls.authors_url = reverse('authordocument-suggest', kwargs={}) cls.created_addresses() call_command('search_index', '--rebuild', '-f')