Ejemplo n.º 1
0
 def test_save_people_data_full_data(self):
     movie_data = {
         'external_id': '1',
         'name': 'name',
         'gender': 'male',
         'age': 'age',
         'eye_color': 'eye_color',
         'hair_color': 'hair_color',
     }
     self.assertIsNone(save_people_data([{**movie_data, 'id': 1}]))
     self.assertEqual(1, People.objects.filter(**movie_data).count())
Ejemplo n.º 2
0
 def test_save_people_data_full_data_with_worng_film_url(self):
     movie_data = {
         'external_id': '1',
         'name': 'name',
         'gender': 'male',
         'age': 'age',
         'eye_color': 'eye_color',
         'hair_color': 'hair_color',
     }
     self.assertIsNone(
         save_people_data([{
             **movie_data, 'id': 1,
             'films': ['test']
         }]))
     self.assertEqual(1, People.objects.filter(**movie_data).count())
     self.assertEqual(0, Movie.objects.all().count())
Ejemplo n.º 3
0
 def test_save_people_data_full_data_with_not_existing_films(self):
     movie_data = {
         'external_id': '1',
         'name': 'name',
         'gender': 'male',
         'age': 'age',
         'eye_color': 'eye_color',
         'hair_color': 'hair_color',
     }
     self.assertIsNone(
         save_people_data([{
             **movie_data, 'id':
             1,
             'films': [
                 'https://ghibliapi.herokuapp.com/films/0440483e-ca0e-4120-8c50-4c8cd9b965d6'
             ]
         }]))
     self.assertEqual(1, People.objects.filter(**movie_data).count())
     self.assertEqual(0, Movie.objects.all().count())
Ejemplo n.º 4
0
 def test_save_people_data_full_data_with_existing_films(self):
     movie = Movie.objects.create(
         external_id='0440483e-ca0e-4120-8c50-4c8cd9b965d6')
     movie_data = {
         'external_id': '1',
         'name': 'name',
         'gender': 'male',
         'age': 'age',
         'eye_color': 'eye_color',
         'hair_color': 'hair_color',
     }
     self.assertIsNone(
         save_people_data([{
             **movie_data, 'id':
             1,
             'films': [
                 'https://ghibliapi.herokuapp.com/films/0440483e-ca0e-4120-8c50-4c8cd9b965d6'
             ]
         }]))
     movie.refresh_from_db()
     person = People.objects.get(**movie_data)
     self.assertEqual(1, movie.people.all().count())
     self.assertEqual(person, movie.people.first())
Ejemplo n.º 5
0
 def test_save_people_data_min_data(self):
     self.assertIsNone(save_people_data([{'id': '1'}, {'id': '2'}]))
     self.assertEqual(
         2,
         People.objects.filter(external_id__in=['1', '2']).count())
Ejemplo n.º 6
0
 def test_save_people_data_empty_list(self):
     self.assertIsNone(save_people_data([]))
     self.assertEqual(0, People.objects.all().count())