Ejemplo n.º 1
0
    def read_csv_file(self):
        with open(self._data_path, mode='r', encoding='utf-8-sig') as f:
            records = csv.DictReader(f)
            for record in records:
                movie = Movie(record.get('Title'), int(record.get('Year', 0)))

                for actor in self._read_field(record, 'Actors', ','):
                    actor = Actor(actor)
                    movie.add_actor(actor)
                    self._dataset_of_actors.add(actor)

                for genre in self._read_field(record, 'Genre', ','):
                    genre = Genre(genre)
                    movie.add_genre(genre)
                    self._dataset_of_genres.add(genre)

                for director in self._read_field(record, 'Director', ','):
                    director = Director(director)
                    movie.set_director(director)
                    self._dataset_of_directors.add(director)

                movie.description = record.get('Description')
                movie.runtime_minutes = int(record.get('Runtime (Minutes)'))

                self._dataset_of_movies.add(movie)
Ejemplo n.º 2
0
def test_set_runtime_minutes():
    movie1 = Movie("Moana", 2016)
    with pytest.raises(ValueError):
        movie1.runtime_minutes = 0
Ejemplo n.º 3
0
def test_get_runtime_minutes():
    movie1 = Movie("Moana", 2016)
    movie1.runtime_minutes = 100
    assert movie1.runtime_minutes == 100