コード例 #1
0
 def test_person_name_transliteration(self):
     person = PersonFactory(first_name='', last_name='', first_name_en='', last_name_en='',
                            first_name_ru='Андрей', last_name_ru='Мягков')
     self.assertEqual(len(person.name), 0)
     person.set_transliteratable_fields()
     self.assertEqual(person.name, person.name_en)
     self.assertGreater(len(person.name), 0)
コード例 #2
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)
コード例 #3
0
 def test_person(self):
     p = PersonFactory(gender=Gender.MALE)
     p_id = global_id(p)
     query = '''
         query Person($id: ID!) {
           person(id: $id) {
             id, gender
             nameEn, firstNameEn, lastNameEn
             nameRu, firstNameRu, lastNameRu
             dateBirth, dateDeath
             country { nameEn }
             roles { nameEn }
           }
         }
     '''
     with self.assertNumQueries(2):
         result = self.execute(query, dict(id=p_id))
     self.assertEqual(result['person']['id'], p_id)
     self.assertEqual(result['person']['nameEn'], p.name_en)
     self.assertEqual(result['person']['nameRu'], p.name_ru)
     self.assertEqual(result['person']['gender'], Gender.MALE.name)
     self.assertEqual(result['person']['dateBirth'], p.date_birth.strftime('%Y-%m-%d'))
     self.assertEqual(result['person']['dateDeath'], p.date_death.strftime('%Y-%m-%d'))
     self.assertEqual(result['person']['country']['nameEn'], p.country.name_en)
     self.assertGreater(len(result['person']['roles']), 0)
     self.assert_m2m_rel(result['person']['roles'], p.roles)
コード例 #4
0
    def test_person_with_career(self):
        person = PersonFactory()
        person.career.add(CastFactory())
        person.career.add(CastFactory())

        self.assertEqual(Movie.objects.count(), 2)
        self.assertEqual(Cast.objects.count(), 2)
        self.assertEqual(person.career.count(), 2)
コード例 #5
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)
コード例 #6
0
 def test_person(self):
     p = PersonFactory()
     self.assertGreater(len(p.first_name), 0)
     self.assertGreater(len(p.last_name), 0)
     self.assertGreater(p.roles.count(), 0)
     self.assertIsNotNone(p.country)
     self.assertIsNotNone(p.date_birth)
     self.assertIsNotNone(p.date_death)
     self.assertIsNotNone(p.gender)
コード例 #7
0
    def test_download_wikipedia_image_for_object(self):
        url = 'http://upload.wikimedia.org/wikipedia/commons/9/9e/Francis_Ford_Coppola_2007_crop.jpg'
        person = PersonFactory()

        link = person.images.download(url, type=ImageType.PHOTO)

        self.assertEqual(link.image.source, 'upload.wikimedia.org')
        self.assertEqual(link.image.source_type, ImageSourceType.WIKICOMMONS)
        self.assertEqual(link.image.source_id,
                         'Francis_Ford_Coppola_2007_crop.jpg')
        self.assertEqual(link.image.type, ImageType.PHOTO)
        self.assertEqual(link.object, person)
        self.assertEqual(link, person.images.last())
コード例 #8
0
 def test_person_without_related_sites(self):
     p = PersonFactory()
     query = '''
         query Person($id: ID!) {
           person(id: $id) {
             id
             imdb { id }
             kinopoisk { id, info }
           }
         }
     '''
     with self.assertNumQueries(1):
         result = self.execute(query, dict(id=global_id(p)))
     self.assertEqual(result['person']['imdb'], None)
     self.assertEqual(result['person']['kinopoisk'], None)
コード例 #9
0
    def test_person_roles(self):
        person = PersonFactory(roles=[])
        CastFactory(person=person, role=Role.objects.get_scenarist())
        for i in range(9):
            CastFactory(person=person, role=Role.objects.get_actor())
        person.set_roles()
        self.assertQuerysetEqual(person.roles.all(), [Role.objects.get_actor().name])

        # exceed threshold
        CastFactory(person=person, role=Role.objects.get_scenarist())
        person.set_roles()
        self.assertQuerysetEqual(person.roles.all(), [Role.objects.get_actor().name, Role.objects.get_scenarist().name])
コード例 #10
0
 def test_person_with_career(self):
     p = PersonFactory()
     for i in range(100):
         cast = CastFactory(person=p)
     CastFactory(role=cast.role)
     query = '''
         query Person($id: ID!, $role: ID!) {
           person(id: $id) {
             id
             career(role: $role) {
               edges {
                 node {
                   name
                   movie { titleEn }
                   role { nameEn }
                 }
               }
             }
           }
         }
     '''
     with self.assertNumQueries(3):
         result = self.execute(query, dict(id=global_id(p), role=global_id(cast.role)))
     self.assertEqual(len(result['person']['career']['edges']), p.career.filter(role=cast.role).count())
コード例 #11
0
 def setUp(self):
     for i in range(self.count):
         PersonFactory()
コード例 #12
0
 def test_person_gender(self):
     for i in range(100):
         PersonFactory()
     self.assertEqual(Person.objects.filter(gender=None).count(), 0)
     self.assertGreater(Person.objects.filter(gender=Gender.MALE).count(), 0)
     self.assertGreater(Person.objects.filter(gender=Gender.FEMALE).count(), 0)
コード例 #13
0
 def jack(self):
     return PersonFactory(first_name_en='Jack', last_name_en='Nicholson',
                          first_name_ru='Джек', last_name_ru='Николсон')
コード例 #14
0
 def test_search_and_sync_person_dennis_hopper(self):
     person = PersonFactory(first_name_en='Dennis', last_name_en='Hopper')
     sync_person(person.id)
     self.assert_dennis_hopper(person.imdb)
コード例 #15
0
 def test_person_url(self):
     person = PersonFactory()
     KinopoiskPerson.objects.create(id=1, person=person)
     self.assertEqual(person.kinopoisk.url,
                      'http://www.kinopoisk.ru/name/1/')
コード例 #16
0
 def test_person_url(self):
     person = PersonFactory()
     ImdbPerson.objects.create(id=1, person=person)
     self.assertEqual(person.imdb.url, 'http://www.imdb.com/name/nm0000001/')