Пример #1
0
 def test_add_roles_to_person_by_imdb_id(self):
     imdb_movie1 = ImdbMovieFactory(
         id=64276)  # Easy rider: director, Billy, writer
     imdb_movie2 = ImdbMovieFactory(
         id=108399)  # True Romance: Clifford Worley
     imdb_person = self.imdb_dennis_hopper()
     imdb_person.sync(roles=True)
     self.assert_dennis_hopper_career(imdb_person, imdb_movie1.movie,
                                      imdb_movie2.movie)
Пример #2
0
 def test_stat_page(self):
     for i in range(100):
         ImdbMovieFactory(movie=KinopoiskMovieFactory().movie)
         ImdbPersonFactory(person=KinopoiskPersonFactory().person)
     with self.assertNumQueries(21):
         response = self.client.get(reverse(f'admin:statistic'))
     self.assertEqual(response.status_code, 200)
Пример #3
0
 def test_movie_with_related_sites(self):
     m = ImdbMovieFactory(movie=KinopoiskMovieFactory().movie).movie
     query = '''
         query Movie($id: ID!) {
           movie(id: $id) {
             id
             imdb { id, rating, votes, url }
             kinopoisk { id, rating, votes, info, url }
           }
         }
     '''
     with self.assertNumQueries(1):
         result = self.execute(query, dict(id=global_id(m)))
     self.assertEqual(result['movie']['imdb']['id'], m.imdb.id)
     self.assertEqual(result['movie']['imdb']['rating'], m.imdb.rating)
     self.assertEqual(result['movie']['imdb']['votes'], m.imdb.votes)
     self.assertEqual(result['movie']['imdb']['url'], m.imdb.url)
     self.assertEqual(result['movie']['kinopoisk']['id'], m.kinopoisk.id)
     self.assertEqual(result['movie']['kinopoisk']['rating'],
                      m.kinopoisk.rating)
     self.assertEqual(result['movie']['kinopoisk']['votes'],
                      m.kinopoisk.votes)
     self.assertEqual(result['movie']['kinopoisk']['info'],
                      m.kinopoisk.info)
     self.assertEqual(result['movie']['kinopoisk']['url'], m.kinopoisk.url)
Пример #4
0
 def test_add_authors_to_movie(self):
     imdb_person = ImdbPersonFactory(id=234502)  # writer, Dostoevskiy
     imdb_movie = ImdbMovieFactory(id=475730)
     imdb_movie.sync(roles=True)
     self.assertTrue(
         imdb_movie.movie.cast.get(person=imdb_person.person,
                                   role=self.author))
Пример #5
0
 def test_add_roles_to_movie_by_names(self):
     person1 = PersonFactory(first_name_en='Lilly',
                             last_name_en='Wachowski')
     person2 = PersonFactory(first_name_en='Keanu', last_name_en='Reeves')
     person3 = PersonFactory(first_name_en='Jeremy', last_name_en='Ball')
     imdb_movie = ImdbMovieFactory(id=133093)
     imdb_movie.sync(roles=True)
     self.assert_matrix_cast(imdb_movie, person1, person2, person3)
Пример #6
0
 def test_search_and_sync_right_person_by_movie(self, search_person):
     person1 = PersonFactory(first_name_en='Allison',
                             last_name_en='Williams')
     person2 = PersonFactory(first_name_en='Allison',
                             last_name_en='Williams')
     person3 = PersonFactory(first_name_en='Allison',
                             last_name_en='Williams')
     ImdbMovieFactory(id=1672719, movie=CastFactory(person=person1).movie)
     ImdbMovieFactory(id=2702724, movie=CastFactory(person=person2).movie)
     ImdbMovieFactory(id=1985034, movie=CastFactory(person=person3).movie)
     sync_person(person1.id)
     sync_person(person2.id)
     sync_person(person3.id)
     self.assertEqual(person1.imdb.id, 930009)
     self.assertEqual(person2.imdb.id, 8050010)
     self.assertEqual(person3.imdb.id, 4613572)
     self.assertFalse(search_person.called)
Пример #7
0
 def test_add_movies_to_writer(self):
     # writer, Dostoevskiy
     imdb_movie = ImdbMovieFactory(id=475730)
     imdb_person = ImdbPersonFactory(id=234502, person__country=None)
     imdb_person.sync(roles=True)
     self.assertTrue(
         imdb_person.person.career.filter(movie=imdb_movie.movie,
                                          role=self.author))
Пример #8
0
 def test_sync_movie_matrix(self):
     imdb_movie = ImdbMovieFactory(id=133093,
                                   movie__year=None,
                                   movie__title='',
                                   movie__genres=[],
                                   movie__languages=[],
                                   movie__countries=[])
     sync_movie(imdb_movie.movie.id, roles=False)
     self.assert_matrix(imdb_movie)
Пример #9
0
 def test_add_roles_to_movie_by_imdb_id(self):
     imdb_person1 = ImdbPersonFactory(
         id=905152)  # Lilly Wachowski: director, scenarist, producer
     imdb_person2 = ImdbPersonFactory(id=206)  # Keanu Reeves: Neo
     imdb_person3 = ImdbPersonFactory(id=50390)  # Jeremy Ball: Businessman
     imdb_movie = ImdbMovieFactory(id=133093)
     imdb_movie.sync(roles=True)
     self.assert_matrix_cast(imdb_movie, imdb_person1.person,
                             imdb_person2.person, imdb_person3.person)
Пример #10
0
 def test_movie_exists_genres_adams_family(self):
     imdb_movie = ImdbMovieFactory(id=57729, movie__genres=[])
     imdb_movie.movie.genres.set(
         [Genre.BLACK_AND_WHITE_ID, Genre.DOCUMENTARY_ID])
     self.assertQuerysetEqual(imdb_movie.movie.genres.all(),
                              ['Black and white', 'Documentary'])
     imdb_movie.sync()
     self.assertQuerysetEqual(imdb_movie.movie.genres.all(), [
         'Black and white', 'Comedy', 'Documentary', 'Family', 'Horror',
         'Series'
     ])
Пример #11
0
 def test_sync_movie_with_wrong_person(self):
     dan_brown_wrong = ImdbPersonFactory(id=1640149,
                                         person__country=None,
                                         person__first_name_en='Dan',
                                         person__last_name_en='Brown')
     imdb_movie = ImdbMovieFactory(id=382625,
                                   movie=CastFactory(
                                       person=dan_brown_wrong.person,
                                       role=self.producer).movie)
     sync_movie(imdb_movie.movie.id, roles='all')
     self.assertTrue(
         imdb_movie.movie.cast.get(role=self.producer,
                                   person__imdb__id=1467010))
Пример #12
0
 def test_add_imdb_id_to_persons_of_movie(self):
     imdb_movie = ImdbMovieFactory(id=133093)
     cast1 = CastFactory(movie=imdb_movie.movie,
                         person__first_name_en='Lilly',
                         person__last_name_en='Wachowski',
                         role=self.director)
     cast2 = CastFactory(movie=imdb_movie.movie,
                         person__first_name_en='Keanu',
                         person__last_name_en='Reeves',
                         role=self.actor)
     cast3 = CastFactory(movie=imdb_movie.movie,
                         person__first_name_en='Jeremy',
                         person__last_name_en='Ball',
                         role=self.actor)
     imdb_movie.sync(roles=True)
     self.assert_matrix_cast(imdb_movie, cast1.person, cast2.person,
                             cast3.person)
Пример #13
0
    def test_sync_all_roles_of_ru_movie_from_imdb_and_kinopoisk(self):
        imdb_movie = ImdbMovieFactory(id=69293)  # solaris
        movie = imdb_movie.movie
        kp_movie = KinopoiskMovieFactory(id=43911, movie=movie)

        kp_movie.sync(roles='all')
        self.assertEqual(movie.cast.count(), 28)
        self.assertEqual(Person.objects.count(), 27)

        imdb_movie.sync(roles='all')
        self.assertEqual(movie.cast.count(), 39)
        self.assertEqual(Person.objects.count(), 37)

        self.assertEqual(
            Person.objects.exclude(kinopoisk=None).exclude(imdb=None).count(),
            18)  # found by translit
        self.assertEqual(Person.objects.filter(kinopoisk=None).count(), 10)
        self.assertEqual(Person.objects.filter(imdb=None).count(), 9)
        self.assertListEqual(
            [p.name for p in Person.objects.filter(kinopoisk=None)], [
                'Andrei Tarkovsky', 'Jüri Järvet', 'Sos Sargsyan',
                'Yulian Semyonov', 'Raimundas Banionis', 'Artyom Karapetyan',
                'Vladimir Tatosov', 'Vladimir Zamanskiy', 'Nina Marcus',
                'Stanislaw Lem'
            ])
        self.assertListEqual(
            [p.name for p in Person.objects.filter(imdb=None)], [
                'Andrey Tarkovskiy', 'Yuri Yarvet', 'Sos Sarkisyan',
                'Yulian Semenov', 'Raymundas Banionis', 'Vyacheslav Tarasov',
                'Stanislav Lem', 'Eduard Artemev', 'Nina Markus'
            ])

        self.assertEqual(Person.objects.filter(first_name='').count(), 0)
        self.assertEqual(Person.objects.filter(last_name='').count(), 0)
        self.assertEqual(Person.objects.filter(first_name_en='').count(), 0)
        self.assertEqual(Person.objects.filter(last_name_en='').count(), 0)
        self.assertEqual(Person.objects.filter(first_name_ru='').count(), 0)
        self.assertEqual(Person.objects.filter(last_name_ru='').count(), 0)

        # check translated role names
        role = movie.cast.get(person__kinopoisk__id=185619)
        self.assertEqual(role.name_ru, 'Хари')
        self.assertEqual(role.name_en, 'Khari')
Пример #14
0
    def test_sync_all_roles_of_movie_from_imdb_and_kinopoisk(self):
        imdb_movie = ImdbMovieFactory(id=64276)  # easy rider
        movie = imdb_movie.movie
        kp_movie = KinopoiskMovieFactory(id=4220, movie=movie)

        kp_movie.sync(roles='all')
        self.assertEqual(movie.cast.count(), 60)
        self.assertEqual(Person.objects.count(), 56)

        imdb_movie.sync(roles='all')
        self.assertEqual(movie.cast.count(), 60)
        self.assertEqual(Person.objects.count(), 56)

        self.assertEqual(Person.objects.filter(kinopoisk=None).count(), 0)
        self.assertEqual(Person.objects.filter(imdb=None).count(), 0)
        self.assertEqual(Person.objects.filter(first_name='').count(), 0)
        self.assertEqual(Person.objects.filter(last_name='').count(), 0)
        self.assertEqual(Person.objects.filter(first_name_en='').count(), 0)
        self.assertEqual(Person.objects.filter(last_name_en='').count(), 0)
        self.assertEqual(Person.objects.filter(first_name_ru='').count(), 0)
        self.assertEqual(Person.objects.filter(last_name_ru='').count(), 0)
Пример #15
0
 def test_sync_all_roles_of_movie(self):
     imdb_movie = ImdbMovieFactory(id=64276)  # Easy rider
     imdb_movie.sync(roles='all')
     self.assertEqual(imdb_movie.movie.cast.count(), 60)
     self.assertEqual(
         imdb_movie.movie.cast.filter(role=self.actor).count(), 49)
     self.assertEqual(
         imdb_movie.movie.cast.filter(role=self.director).count(), 1)
     self.assertEqual(
         imdb_movie.movie.cast.filter(role=self.producer).count(), 4)
     self.assertEqual(
         imdb_movie.movie.cast.filter(role=self.scenarist).count(), 3)
     self.assertEqual(
         imdb_movie.movie.cast.filter(role=self.operator).count(), 2)
     self.assertEqual(
         imdb_movie.movie.cast.filter(role=self.editor).count(), 1)
     self.assertEqual(Person.objects.count(), 56)
     self.assertEqual(Person.objects.filter(imdb=None).count(), 0)
     self.assertEqual(Person.objects.filter(first_name='').count(), 0)
     self.assertEqual(Person.objects.filter(last_name='').count(), 0)
     self.assertEqual(Person.objects.filter(first_name_en='').count(), 0)
     self.assertEqual(Person.objects.filter(last_name_en='').count(), 0)
Пример #16
0
 def test_sync_movie_series_episode(self):
     imdb_movie = ImdbMovieFactory(id=9236792)
     sync_movie(imdb_movie.movie.id, roles=False)
     with self.assertRaises(ImdbMovieFactory._meta.model.DoesNotExist):
         imdb_movie.refresh_from_db()
Пример #17
0
 def test_movie_title_en(self):
     imdb_movie = ImdbMovieFactory(id=190332)
     imdb_movie.sync()
     self.assertEqual(imdb_movie.movie.title_original, 'Wo hu cang long')
     self.assertEqual(imdb_movie.movie.title_en,
                      'Crouching Tiger, Hidden Dragon')
Пример #18
0
 def test_get_movie_runtime_different_format(self):
     # runtime in format "xxxxx:17"
     imdb_movie = ImdbMovieFactory(id=1524546)
     imdb_movie.sync()
     self.assertEqual(imdb_movie.movie.runtime, 17)
Пример #19
0
 def test_movie_genres_adams_family(self):
     imdb_movie = ImdbMovieFactory(id=57729, movie__genres=[])
     imdb_movie.sync()
     self.assertQuerysetEqual(
         imdb_movie.movie.genres.all(),
         ['Black and white', 'Comedy', 'Family', 'Horror', 'Series'])
Пример #20
0
 def test_movie_genres_no_black_and_white_easy_rider(self):
     imdb_movie = ImdbMovieFactory(id=64276, movie__genres=[])
     imdb_movie.sync()
     self.assertQuerysetEqual(imdb_movie.movie.genres.all(),
                              ['Adventure', 'Drama'])