def test_repository_can_add_movie(session_factory): repo = SqlAlchemyRepository(session_factory) movie = Movie('Guardians of the Galaxy', 2014) movie.runtime_minutes = 121 movie.actors = [ Actor('Chris Pratt'), Actor('Vin Diesel'), Actor('Bradley Cooper'), Actor('Zoe Saldana') ] movie.genres = [Genre('Action'), Genre('Adventure'), Genre('Sci-Fi')] movie.description = "A group of intergalactic criminals are forced to work together to stop a fanatical warrior from taking control of the universe." movie.director = [Director('James Gunn')] movie.rating = 8.1 movie.meta = 76 movie.revenue = 333.13 movie.vote = 757074 repo.add_movie(1, 'Guardians of the Galaxy', 2014, movie.description, 'James Gunn', 'Chris Pratt, Vin Diesel, Bradley Cooper, Zoe Saldana', 'Action,Adventure,Sci-Fi', movie.runtime_minutes, movie.rating, movie.revenue, movie.meta, movie.vote) assert repo.get_movie("Guardians of the Galaxy") == movie
def movie(): movie = Movie('Guardians of the Galaxy', 2014) movie.runtime_minutes = 121 movie.actors = [ Actor('Chris Pratt'), Actor('Vin Diesel'), Actor('Bradley Cooper'), Actor('Zoe Saldana') ] movie.genres = [Genre('Action'), Genre('Adventure'), Genre('Sci-Fi')] movie.description = "A group of intergalactic criminals are forced to work together to stop a fanatical warrior from taking control of the universe." movie.director = Director('James Gunn') movie.rating = 8.1 movie.meta = 76 movie.revenue = 333.13 movie.vote = 757074 return movie
def add_movie(self, title, year, description, director, actor, genre, runtime, rating, revenue, meta, vote): movie = Movie(title, year) movie.description = description movie.director = Director(director) actors = actor.split(",") for a in actors: movie.add_actor(Actor(a.strip())) genres = genre.split(",") for g in genres: movie.add_genre(Genre(g)) movie.runtime = runtime movie.rating = rating if revenue != "N/A": movie.revenue = float(revenue) if meta != "N/A": movie.meta = int(meta) movie.vote = vote self.dataset_of_movies.append(movie)
def add_movie(self, id, title, year, description, director, actor, genre, runtime, rating, revenue, meta, vote): movie = Movie(title, year) movie.description = description movie.director = [Director(director)] actors = actor.split(",") for a in actors: movie.add_actor(Actor(a.strip())) genres = genre.split(",") for g in genres: movie.add_genre(Genre(g)) movie.runtime = runtime movie.rating = rating if revenue != "N/A": movie.revenue = float(revenue) if meta != "N/A": movie.meta = int(meta) movie.vote = vote movie.id = id with self._session_cm as scm: scm.session.add(movie) scm.commit()