def test_genres(): movie1 = Movie("Spirited Away", 2000) movie2 = Movie("Your Name", 2000) movie3 = Movie("Batman", 2000) movie4 = Movie(None, None) movie1.genres = [Genre("Comedy"), Genre("Horror"), Genre("Sci-fi")] assert movie1.genres == [Genre("Comedy"), Genre("Horror"), Genre("Sci-fi")] movie2.genres = [Genre("Comedy"), Genre("Horror"), Genre("Sci-fi"), 12345] assert movie2.genres == [] movie3.genres = Genre("Comedy") assert movie3.genres == [Genre("Comedy")] movie4.genres = "Comedy" assert movie4.genres == []
def test_add_genre(): movie1 = Movie("Spirited Away", 2000) movie1.genres = [Genre("Comedy")] movie1.add_genre(Genre("Horror")) assert movie1.genres == [Genre("Comedy"), Genre("Horror")] movie1.add_genre("Scifi") movie1.add_genre(Genre("Hhiya")) movie1.add_genre("") movie1.add_genre(None) movie1.add_genre(21345648) assert movie1.genres == [Genre("Comedy"), Genre("Horror"), Genre("Hhiya")]
def remove_genre(): movie1 = Movie("Spirited Away", 2000) movie1.genres = [Genre("Comedy")] movie1.add_genre(Genre("Horror")) movie1.add_genre(Genre("Happy ending")) assert movie1.genres == [ Genre("Comedy"), Genre("Horror"), Genre("Happy ending") ] movie1.remove_genre("Scifi") movie1.remove_genre(Genre("Hhiya")) movie1.remove_genre("") movie1.remove_genre(None) movie1.remove_genre(21345648) movie1.remove_genre(Genre("Happy ending")) assert movie1.genres == [Genre("Comedy"), Genre("Horror")] movie1.remove_genre(Genre("Comedy")) assert movie1.genres == [Genre("Horror")] movie1.remove_genre(Genre("Horror")) assert movie1.genres == []