def test_tv_mini_series(self): """ Test case when imdb movie has kind==tv mini-series """ self.initialize() self.client.login(username=self.user.username, password='******') film_to_import = FilmToImport(user = self.user, title = 'Battlestar Galactica', imdb_url = 'http://www.imdb.com/title/tt0314979/', imdb_id='0314979', status=FilmToImport.ACCEPTED) film_to_import.save() run(False, False, False, False, False, True, "http") # there is only 1 film to import in db film_to_import = FilmToImport.objects.get(title="Battlestar Galactica") self.assertEqual(film_to_import.is_imported, True) #film is imported imported_film = ImportedFilm.objects.get(film__permalink="battlestar-galactica") self.assertEqual(imported_film.film.permalink, "battlestar-galactica") film = Film.objects.get(permalink="battlestar-galactica") self.assertEqual(film.permalink, "battlestar-galactica") self.assertEqual(film.title, "Battlestar Galactica") self.assertEqual(film.imdb_code, "0314979")
def test_gofigure(self): """ Proof that imdb_fetcher is able to fetch TV movie Go Figure http://www.imdb.com/title/tt0447987/ """ self.initialize() self.client.login(username=self.user.username, password='******') film_to_import = FilmToImport(user = self.user, title = 'Go Figure', imdb_url = 'http://www.imdb.com/title/tt0447987/', imdb_id='0447987', status=FilmToImport.ACCEPTED) film_to_import.save() run(False, False, False, False, False, True, "http") # there is only 1 film to import in db film_to_import = FilmToImport.objects.get(title="Go Figure") self.assertEqual(film_to_import.is_imported, True) #film is imported imported_film = ImportedFilm.objects.get(film__permalink="go-figure") self.assertEqual(imported_film.film.permalink, "go-figure") film = Film.objects.get(permalink="go-figure") self.assertEqual(film.tmdb_import_status, Film.IMPORTED) self.assertEqual(film.permalink, "go-figure") self.assertEqual(film.title, "Go Figure") self.assertEqual(film.imdb_code, "0447987")
def test_posterfetch(self): """ Test case when there is no poster in imdb and poster is in tmdb db """ self.initialize() self.client.login(username=self.user.username, password='******') film_to_import = FilmToImport(user = self.user, title = 'Zaat', imdb_url = 'http://www.imdb.com/title/tt0072666/', imdb_id='0072666', status=FilmToImport.ACCEPTED) film_to_import.save() run(False, False, False, False, False, True, "http") # there is only 1 film to import in db film_to_import = FilmToImport.objects.get(title="Zaat") self.assertEqual(film_to_import.is_imported, True) #film is imported imported_film = ImportedFilm.objects.get(film__permalink="zaat") self.assertEqual(imported_film.film.permalink, "zaat") film = Film.objects.get(permalink="zaat") self.assertEqual(film.tmdb_import_status, Film.IMPORTED) self.assertEqual(film.permalink, "zaat") self.assertEqual(film.title, "Zaat") self.assertEqual(film.imdb_code, "0072666")
def person_wrong_name( self ): self.initialize() person = Person() person.name = "Ela" person.surname = "Gabor" person.permalink = "ela-gabor" person.imdb_code = "3140529" person.verified_imdb_code = True person.type = Person.TYPE_PERSON person.save() fti1 = FilmToImport( user = self.user, title = '180/100', imdb_url = 'http://www.imdb.com/title/tt2089598/', imdb_id = '2089598', status = FilmToImport.ACCEPTED ) fti1.save() run( False, False, False, False, False, True, "http" ) self.assertEqual( Person.objects.filter( imdb_code__isnull=True ).count(), 0 ) person = Person.objects.get( imdb_code="3140529" ) self.assertEqual( person.name, "Ela" ) self.assertEqual( person.surname, "Gabor" ) self.assertEqual( person.permalink, "ela-gabor" ) self.assertEqual( person.import_comment, "imdb name: Éva Gábor" )
def match_and_save(self): title = self.title title_norm = normalized_text(title) or title year = self.year directors = (d.strip() for d in (self.directors or '').split(',')) tag = self.tag film = None candidates = [] match = UNMATCHED if self.imdb_code: try: film = Film.objects.get(imdb_code=self.imdb_code) logger.debug("matched by imdb_code: %r", film) match = MATCHED except Film.DoesNotExist, e: admin = User.objects.get(username='******') try: to_import = FilmToImport.objects.get(imdb_id=self.imdb_code, comment='showtimes auto-import', user=admin) except FilmToImport.DoesNotExist: to_import = FilmToImport( user = admin, title = self.title, imdb_url = 'http://www.imdb.com/title/tt/%s/' % self.imdb_code, imdb_id = self.imdb_code, comment = 'showtimes auto-import', status = FilmToImport.ACCEPTED, ) if to_import.status == FilmToImport.ACCEPTED: to_import.is_imported = False to_import.attempts = 0 to_import.save()
def match_and_save(self, save=True): film = None candidates = [] match = UNMATCHED if self.imdb_code: try: film = Film.objects.get(imdb_code=self.imdb_code) logger.debug("matched by imdb_code: %r", film) match = MATCHED except Film.DoesNotExist, e: admin = User.objects.get(username='******') try: to_import = FilmToImport.objects.get(imdb_id=self.imdb_code, comment='showtimes auto-import', user=admin) except FilmToImport.DoesNotExist: to_import = FilmToImport( user = admin, title = self.title, imdb_url = 'http://www.imdb.com/title/tt/%s/' % self.imdb_code, imdb_id = self.imdb_code, comment = 'showtimes auto-import', status = FilmToImport.ACCEPTED, ) if to_import.status == FilmToImport.ACCEPTED: to_import.is_imported = False to_import.attempts = 0 to_import.save()
def test_filmindb(self): """ Test failed fetch movie in db """ self.initialize() self.client.login(username=self.user.username, password='******') film_to_import = FilmToImport(user = self.user, title = 'Elektroniczny Morderca', imdb_url = 'http://www.imdb.com/title/tt0088247/', imdb_id='0088247', status=FilmToImport.ACCEPTED) film_to_import.save() film = Film() film.title = "The Terminator" film.type = Object.TYPE_FILM film.imdb_code = "0088247" film.permalink = "the-terminator" film.release_year = 1984 film.save() run(False, False, False, False, False, True, "http") film_to_import = FilmToImport.objects.get(title = 'Elektroniczny Morderca') self.assertEqual(film_to_import.attempts, 1) self.assertEqual(film_to_import.status, FilmToImport.ALREADY_IN_DB)
def test_tvseries(self): """ Film to import is a tv series or something went wrong during fetching page from imdb """ self.initialize() self.client.login(username=self.user.username, password='******') film_to_import = FilmToImport(user = self.user, title = 'The A-Team', imdb_url = 'http://www.imdb.com/title/tt0084967/', imdb_id='0084967', status=FilmToImport.ACCEPTED) film_to_import.save() run(False, False, False, False, False, True, "http") film_to_import = FilmToImport.objects.get(title = 'The A-Team') self.assertEqual(film_to_import.status, FilmToImport.TV_SERIES)
def match_and_save(self, save=True): film = None candidates = [] match = UNMATCHED if self.imdb_code: try: film = Film.objects.get(imdb_code=self.imdb_code) logger.debug("matched by imdb_code: %r", film) match = MATCHED except Film.DoesNotExist, e: admin = User.objects.get(username='******') try: to_import = FilmToImport.objects.get( imdb_id=self.imdb_code, comment='showtimes auto-import', user=admin) except FilmToImport.DoesNotExist: to_import = FilmToImport( user=admin, title=self.title, imdb_url='http://www.imdb.com/title/tt/%s/' % self.imdb_code, imdb_id=self.imdb_code, comment='showtimes auto-import', status=FilmToImport.ACCEPTED, ) if to_import.status == FilmToImport.ACCEPTED: to_import.is_imported = False to_import.attempts = 0 to_import.save()
def duplicate_imdb_code(self): """ ImdbFetcher is trying to save person with imdb_code, already existing in db """ self.initialize() self.client.login(username=self.user.username, password='******') per = Person() per.name = "Jan" per.surname = "Kowalski" # Schwarzeneger's imdb code per.imdb_code = "0000216" per.type = Person.TYPE_PERSON per.save() per = Person.objects.get(imdb_code="0000216") self.assertEqual(per.name, "Jan") self.assertEqual(per.imdb_code, "0000216") film_to_import = FilmToImport(user = self.user, title = 'Terminator', imdb_url = 'http://www.imdb.com/title/tt0088247/', imdb_id='0088247', status=FilmToImport.ACCEPTED) film_to_import.save() run(False, False, False, False, False, True, "http") person = Person.objects.get(imdb_code="0000216") # duplicate imdb_code - should be set to Schwarzenegger self.assertEqual(person.name, "Arnold") self.assertEqual(person.surname, "Schwarzenegger") self.assertEqual(person.verified_imdb_code, True) self.assertEqual(person.imdb_code, "0000216") # old imdb_code should be set to None per = Person.objects.get(name="Jan", surname="Kowalski") self.assertEqual(per.imdb_code, None)
def unique_imdb_code(self): """ There is a person in db but, he has different imdb_code """ self.initialize() self.client.login(username=self.user.username, password='******') per = Person() per.name = "Jan" per.surname = "Kowalski" # Schwarzeneger's imdb code per.imdb_code = "0101010101010101" per.type = Person.TYPE_PERSON per.save() per = Person.objects.get(imdb_code="0101010101010101") self.assertEqual(per.name, "Jan") self.assertEqual(per.imdb_code, "0101010101010101") film_to_import = FilmToImport(user = self.user, title = 'Terminator', imdb_url = 'http://www.imdb.com/title/tt0088247/', imdb_id='0088247', status=FilmToImport.ACCEPTED) film_to_import.save() run(False, False, False, False, False, True, "http") person = Person.objects.get(imdb_code="0000216") self.assertEqual(person.name, "Arnold") self.assertEqual(person.surname, "Schwarzenegger") self.assertEqual(person.verified_imdb_code, True) self.assertEqual(person.imdb_code, "0000216") # old imdb_code should be set to None per = Person.objects.get(name="Jan", surname="Kowalski") self.assertEqual(per.imdb_code, "0101010101010101")
def test_successfullfetch(self): """ Test successfull fetch """ self.client.login(username=self.user.username, password='******') self.initialize() film_to_import = FilmToImport(user = self.user, title = 'Elektroniczny Morderca', imdb_url = 'http://www.imdb.com/title/tt0088247/', imdb_id='0088247', status=FilmToImport.ACCEPTED) film_to_import.save() run(False, False, False, False, False, True, "http") # there is only 1 film to import in db film_to_import = FilmToImport.objects.get(id=1) self.assertEqual(film_to_import.is_imported, True) #film is imported imported_film = ImportedFilm.objects.get(id=1) self.assertEqual(imported_film.film.permalink, "the-terminator") film = Film.objects.get(permalink="the-terminator") self.assertEqual(film.permalink, "the-terminator") self.assertEqual(film.imdb_code, "0088247") self.assertEqual(film.title, "The Terminator") self.assertEqual(film.release_year, 1984) self.assertEqual(film.image is not None, True) self.assertEqual(film.production_country_list, "UK,USA")
def import_film(request): imported_films = ImportedFilm.objects.all().order_by("-created_at") if request.user.is_authenticated() & (request.method == 'POST'): form = FilmToImportForm(request.user, request.POST) if form.is_valid(): film_to_import = form.save(commit=False) film_to_import.user = request.user if form.cleaned_data['imdb_url']: url = form.cleaned_data['imdb_url'] line = re.search('/tt(\d+)/', url) if line <> None: film_to_import.imdb_id = line.group(1).strip() film_to_import.save() form = FilmToImportForm() # if user has perm to accept film, do this now if request.user.has_perm('import_films.can_accept_films'): film_to_import.accept(request.user) message = _("Film added to import!") else: message = _("Thank you for this suggestion!") messages.add_message(request, messages.INFO, message) data = { 'imported_films': imported_films, 'form': form, } return render_to_response(templates['ADD_FILM'], data, context_instance=RequestContext(request)) else: imdb_id = request.GET.get('imdb_id', '') imdb_url = 'http://www.imdb.com/title/tt' + request.GET.get( 'imdb_id', '') + '/' if imdb_id else '' title = request.GET.get('title') form = FilmToImportForm(instance=FilmToImport( imdb_id=imdb_id, imdb_url=imdb_url, title=title)) data = { 'imported_films': imported_films, 'form': form, } return render_to_response(templates['ADD_FILM'], data, context_instance=RequestContext(request))
def testNotification(self): from django.core import mail from django.contrib.auth.models import User from film20.import_films.models import FilmToImport from film20.import_films.imdb_fetcher import run u1 = User(username='******', email='*****@*****.**') u1.save() f1 = FilmToImport(user=u1, title='The Expandables', imdb_url='http://www.imdb.com/title/tt1320253/', imdb_id='1320253', status=FilmToImport.ACCEPTED) f1.save() # clear test outbox mail.outbox = [] run(False, False, False, False, False, True, "http") self.assertEqual(len(mail.outbox), 1) film = Film.objects.get(imdb_code=f1.imdb_id) self.assertFalse("http://fail-test/film" in mail.outbox[0].body) self.assertTrue(film.get_absolute_url() in mail.outbox[0].body) # try retrive once again f1.status = FilmToImport.ACCEPTED f1.save() mail.outbox = [] run(False, False, False, False, False, True, "http") self.assertEqual(len(mail.outbox), 1) f1 = FilmToImport.objects.get(pk=f1.pk) self.assertEqual(f1.status, FilmToImport.ALREADY_IN_DB) self.assertTrue(film.get_absolute_url() in mail.outbox[0].body)
def persons_with_same_name( self ): self.initialize() fti1 = FilmToImport( user = self.user, title = '180/100', imdb_url = 'http://www.imdb.com/title/tt2089598/', imdb_id = '2089598', status = FilmToImport.ACCEPTED ) fti1.save() fti2 = FilmToImport( user = self.user, title = 'The Mad Magician', imdb_url = 'http://www.imdb.com/title/tt0047200/', imdb_id = '0047200', status = FilmToImport.ACCEPTED ) fti2.save() run( False, False, False, False, False, True, "http" ) person = Person.objects.get( imdb_code="3140529" ) self.assertEqual( person.name, "Éva" ) self.assertEqual( person.surname, "Gábor" ) self.assertEqual( person.permalink, "eva-gabor" ) self.assertEqual( person.verified_imdb_code, True ) person = Person.objects.get( imdb_code="0001247" ) self.assertEqual( person.name, "Eva" ) self.assertEqual( person.surname, "Gabor" ) self.assertEqual( person.permalink, "eva-gabor-ii" ) self.assertEqual( person.verified_imdb_code, True )
def testNotification( self ): from django.core import mail from django.contrib.auth.models import User from film20.import_films.models import FilmToImport from film20.import_films.imdb_fetcher import run u1 = User(username='******', email='*****@*****.**') u1.save() f1 = FilmToImport( user = u1, title = 'The Expandables', imdb_url = 'http://www.imdb.com/title/tt1320253/', imdb_id='1320253', status=FilmToImport.ACCEPTED ) f1.save() # clear test outbox mail.outbox = [] run( False, False, False, False, False, True, "http" ) self.assertEqual( len( mail.outbox ), 1 ) film = Film.objects.get( imdb_code=f1.imdb_id ) self.assertFalse( "http://fail-test/film" in mail.outbox[0].body ) self.assertTrue( film.get_absolute_url() in mail.outbox[0].body ) # try retrive once again f1.status=FilmToImport.ACCEPTED f1.save() mail.outbox = [] run( False, False, False, False, False, True, "http" ) self.assertEqual( len( mail.outbox ), 1 ) f1 = FilmToImport.objects.get( pk=f1.pk ) self.assertEqual( f1.status, FilmToImport.ALREADY_IN_DB ) self.assertTrue( film.get_absolute_url() in mail.outbox[0].body )
def test_persons( self ): fti1 = FilmToImport( user=self.user, title='Nybyggarna', imdb_url='http://www.imdb.com/title/tt0069035/', imdb_id='0069035', status=FilmToImport.ACCEPTED ) fti1.save() fti2 = FilmToImport( user=self.user, title='Utvandrarna', imdb_url='http://www.imdb.com/title/tt0067919/', imdb_id='0067919', status=FilmToImport.ACCEPTED ) fti2.save() fti3 = FilmToImport( user=self.user, title='Sandade Sandadi', imdb_url='http://www.imdb.com/title/tt0338408/', imdb_id='0338408', status=FilmToImport.ACCEPTED ) fti3.save() fti4 = FilmToImport( user = self.user, title = 'Journey to shiloh', imdb_url = 'http://www.imdb.com/title/tt0063161/', imdb_id = '0063161', status = FilmToImport.ACCEPTED ) fti4.save() fti5 = FilmToImport( user = self.user, title = 'Guys choice Awards 2011', imdb_url = 'http://www.imdb.com/title/tt2023505/', imdb_id = '2023505', status = FilmToImport.ACCEPTED ) fti5.save() self.assertTrue( compare( "Penélope Cruz", "Penélope Cruz", 2 ) ) fti6 = FilmToImport( user=self.user, title='Volver', imdb_url='http://www.imdb.com/title/tt0441909/', imdb_id='0441909', status=FilmToImport.ACCEPTED ) fti6.save() fti7 = FilmToImport( user=self.user, title='Gothika', imdb_url='http://www.imdb.com/title/tt0348836/', imdb_id='0348836', status=FilmToImport.ACCEPTED ) fti7.save() run( False, False, False, False, False, True, "http" ) self.assertEqual( Film.objects.count(), 7 ) self.assertEqual( Person.objects.filter( name='Harrison', surname='Ford', imdb_code='0000148', verified_imdb_code=True ).count(), 1 ) self.assertEqual( Person.objects.filter( name='Yvonne', surname='Oppstedt', imdb_code='0649235', verified_imdb_code=True ).count(), 1 ) self.assertEqual( Person.objects.filter( name='Sonali', surname='Joshi', imdb_code='1359890', verified_imdb_code=True ).count(), 1 ) self.assertEqual( Film.objects.filter( character__person__imdb_code='0649235' ).distinct().count(), 2 ) self.assertEqual( Film.objects.filter( character__person__imdb_code='1359890' ).distinct().count(), 1 ) # 1. two persons merged f1 = Film.objects.get( imdb_code='0338408' ) yvonne = Person.objects.get( imdb_code='0649235' ) sonali = Person.objects.get( imdb_code='1359890' ) for ch in Character.objects.filter( person=sonali, film=f1 ): ch.person = yvonne ch.save() self.assertEqual( Film.objects.filter( character__person=yvonne ).distinct().count(), 3 ) self.assertEqual( Film.objects.filter( character__person=sonali ).distinct().count(), 0 ) sonali.delete() yvonne.imdb_code = '1359890' yvonne.verified_imdb_code = False yvonne.import_comment = 'imdb name: Sonali Joshi' yvonne.save() # 2. one person with two movies f2 = Film.objects.get( imdb_code='2023505' ) harrison = Person.objects.get( imdb_code='0000148' ) bad_harrison = Person() bad_harrison.name = "Harrison" bad_harrison.surname = "Ford" bad_harrison.permalink = "harrison-ford-1" bad_harrison.type = Person.TYPE_PERSON bad_harrison.save() for ch in Character.objects.filter( person=harrison, film=f2 ): ch.person = bad_harrison ch.save() harrison.verified_imdb_code = False harrison.imdb_code = '111111' harrison.save() bad_harrison.verified_imdb_code = True bad_harrison.imdb_code = '0000148' bad_harrison.save() self.assertEqual( Film.objects.filter( character__person=harrison ).distinct().count(), 1 ) self.assertEqual( Film.objects.filter( character__person=bad_harrison ).distinct().count(), 1 ) self.assertEqual( Person.objects.filter( verified_imdb_code=False ).count(), 2 ) # 3. short imdb code duplicated self.assertEqual( Person.objects.filter( imdb_code='0880521', name='Liv', surname='Ullmann' ).count(), 1 ) liv = Person.objects.get( imdb_code='0880521' ) liv.permalink = 'liv-ullmann-1' liv.save() short_liv = Person() short_liv.imdb_code = '880521' short_liv.name = 'Liv' short_liv.surname = 'Ullmann' short_liv.permalink = 'liv-ullmann' short_liv.type = Person.TYPE_PERSON short_liv.save() # 4. not verified imdb_code self.assertEqual( Person.objects.filter( imdb_code='0005493', name='Justin', surname='Timberlake', verified_imdb_code=True ).count(), 1 ) justin = Person.objects.get( imdb_code='0005493' ) justin.verified_imdb_code = False justin.imdb_code = None justin.save() self.assertEqual( Person.objects.filter( imdb_code='0873296', name='Jan', surname='Troell', verified_imdb_code=True ).count(), 1 ) jan = Person.objects.get( imdb_code='0873296' ) jan.verified_imdb_code = False jan.save() # 5. html entities in name self.assertEqual( Person.objects.filter( name='Penélope', surname='Cruz', imdb_code='0004851', verified_imdb_code=True ).count(), 1 ) penelope = Person.objects.get( imdb_code='0004851' ) gothika = Film.objects.get( imdb_code='0348836' ) penelope.verified_imdb_code = False penelope.imdb_code = '4851' penelope.save() bad_penelope = Person() bad_penelope.name = "Penélope" bad_penelope.surname = "Cruz" bad_penelope.imdb_code = '0004851' bad_penelope.permalink = "penxe9lope-cruz" bad_penelope.type = Person.TYPE_PERSON bad_penelope.save() for ch in Character.objects.filter( person=penelope, film=gothika ): ch.person = bad_penelope ch.save() call_command( 'fix_imported_persons' ) #for p in Person.objects.all(): # print p.verified_imdb_code, p, p.imdb_code, p.import_comment self.assertEqual( Person.objects.filter( verified_imdb_code=False ).count(), 1 ) self.assertEqual( Film.objects.filter( character__person=harrison ).distinct().count(), 2 ) self.assertEqual( Person.objects.get( pk=yvonne.pk ).import_comment, 'imdb name: Sonali Joshi, not matched movies: 0338408' ) self.assertEqual( Person.objects.filter( imdb_code='880521' ).count(), 0 ) self.assertEqual( Person.objects.filter( imdb_code='0880521', name='Liv', surname='Ullmann' ).count(), 1 ) justin = Person.objects.get( pk=justin.pk ) self.assertEqual( justin.imdb_code, '0005493' ) self.assertTrue( justin.verified_imdb_code ) jan = Person.objects.get( pk=jan.pk ) self.assertEqual( jan.imdb_code, '0873296' ) self.assertTrue( jan.verified_imdb_code ) self.assertEqual( Person.objects.filter( name='Penélope', surname='Cruz', imdb_code='0004851', verified_imdb_code=True ).count(), 1 ) acted = Film.objects.filter( character__person=penelope ).distinct() self.assertTrue( len( acted ), 2 )
def test_many_movies_with_the_same_title(self): self. initialize() self.client.login(username=self.user.username, password='******') weekend1 = FilmToImport(user = self.user, title = 'Weekend1', imdb_url = 'http://www.imdb.com/title/tt1791679/', imdb_id='1791679', status=FilmToImport.ACCEPTED) weekend1.save() weekend2 = FilmToImport(user = self.user, title = 'Weekend2', imdb_url = 'http://www.imdb.com/title/tt1714210/', imdb_id='1714210', status=FilmToImport.ACCEPTED) weekend2.save() weekend3 = FilmToImport(user = self.user, title = 'Weekend3', imdb_url = 'http://www.imdb.com/title/tt1910670/', imdb_id='1910670', status=FilmToImport.ACCEPTED) weekend3.save() weekend4 = FilmToImport(user = self.user, title = 'Weekend4', imdb_url = 'http://www.imdb.com/title/tt0124926/', imdb_id='0124926', status=FilmToImport.ACCEPTED) weekend4.save() weekend5 = FilmToImport(user = self.user, title = 'Weekend5', imdb_url = 'http://www.imdb.com/title/tt0177364/', imdb_id='0177364', status=FilmToImport.ACCEPTED) weekend5.save() weekend6 = FilmToImport(user = self.user, title = 'Weekend6', imdb_url = 'http://www.imdb.com/title/tt0145571/', imdb_id='0145571', status=FilmToImport.ACCEPTED) weekend6.save() # duplicated IMDB code weekend7 = FilmToImport(user = self.user, title = 'Weekend1', imdb_url = 'http://www.imdb.com/title/tt1791679/', imdb_id='1791679', status=FilmToImport.ACCEPTED) weekend7.save() films_to_import = FilmToImport.objects.all() self.assertEqual(films_to_import.count(), 7) films_to_import = FilmToImport.objects.filter(is_imported = False, status=FilmToImport.ACCEPTED) self.assertEqual(films_to_import.count(), 7) run(False, False, False, False, False, True, "http") films_to_import = FilmToImport.objects.filter(is_imported = False, status=FilmToImport.ACCEPTED) # all films imported self.assertEqual(films_to_import.count(), 0) imported_films = ImportedFilm.objects.all() # imported films self.assertEqual(imported_films.count(), 6) films = Film.objects.all().order_by('id') self.assertEqual(films.count(), 6) self.assertEqual(films[0].permalink,'weekend') self.assertEqual(films[1].permalink,'weekend-2011') self.assertEqual(films[2].permalink,'weekend-2011-1') self.assertEqual(films[3].permalink,'weekend-1962') self.assertEqual(films[4].permalink,'weekend-1998') self.assertEqual(films[5].permalink,'weekend-1998-1')
def person_short_imdb_code( self ): self.initialize() person = Person() person.name = "Harrison" person.surname = "Ford" person.permalink = "harrison-ford" person.imdb_code = "148" person.type = Person.TYPE_PERSON person.save() person = Person() person.name = "Harrison" person.surname = "Ford (II)" person.permalink = "harrison-ford-ii" person.imdb_code = "0001230" person.type = Person.TYPE_PERSON person.save() self.assertEqual( Person.objects.filter( imdb_code='148' ).count(), 1 ) fti1 = FilmToImport( user = self.user, title = 'Love in High Gear', imdb_url = 'http://www.imdb.com/title/tt0022093/', imdb_id = '0022093', status = FilmToImport.ACCEPTED ) fti1.save() fti2 = FilmToImport( user = self.user, title = 'Journey to shiloh', imdb_url = 'http://www.imdb.com/title/tt0063161/', imdb_id = '0063161', status = FilmToImport.ACCEPTED ) fti2.save() fti3 = FilmToImport( user = self.user, title = 'Guys choice Awards 2011', imdb_url = 'http://www.imdb.com/title/tt2023505/', imdb_id = '2023505', status = FilmToImport.ACCEPTED ) fti3.save() run( False, False, False, False, False, True, "http" ) self.assertEqual( Person.objects.filter( name='Harrison', surname__contains='Ford' ).count(), 2 ) self.assertEqual( Person.objects.filter( imdb_code='148' ).count(), 0 ) self.assertEqual( Person.objects.get( imdb_code='0000148' ).permalink, 'harrison-ford' )