Ejemplo n.º 1
0
class TestRoom(unittest.TestCase):
    def setUp(self):
        # self.room1 = Room("Osaka", 5, 20)
        self.room = Room("Tokyo", 3, 20)

        self.song1 = Song("Fleetwood Mac", "The Chain")
        self.song2 = Song("Dubliners", "The Rocky Road to Dublin")
        self.song3 = Song("Kate Bush", "Wuthering Heights")

        self.guest1 = Guest("Stevie", 39, "The Chain", 10)
        self.guest2 = Guest("Luke", 45, "The Rocky Road to Dublin", 150)
        self.guest3 = Guest("Cathy", 31, "Wuthering Heights", 200)

    def test_room_name(self):
        room_name = "Tokyo"
        self.assertEqual(room_name, self.room.name)

    def test_room_capacity(self):
        self.assertEqual(3, self.room.capacity)

    def test_room_fee(self):
        self.assertEqual(20, self.room.fee)

    def test_song_start_at_0(self):
        self.assertEqual(0, self.room.song_count())

    def test_add_song(self):
        self.room.add_song(self.song1)
        self.assertEqual(1, self.room.song_count())

    def test_room_current_capacity(self):
        self.assertEqual(0, self.room.current_capacity())

    def test_add_guest(self):
        self.room.add_guest(self.guest1)
        self.assertEqual(1, self.room.current_capacity())

    def test_find_song(self):
        song = "The Chain"
        self.room.find_song(self.room.song_list)
        self.assertEqual(song, self.guest1.fav_song)

    def test_check_in(self):
        self.room.check_in(self.guest1)
        self.assertEqual(["Stevie"], self.room.guest_list)
Ejemplo n.º 2
0
class TestRoom(unittest.TestCase):
    def setUp(self):
        self.room = Room("Bollywood", 3, 5, 10)
        # self.room_2 = Room("Tollywood", 5, 10, 20)
        self.guest = Guest("Abhi", 20, 30)
        # self.guest_2 = Guest("Rakesh", 29, 20)
        # self.guest_3 = Guest("Tarun", 40, 60)
        self.song = Song("Sunoh", "Lucky Ali", 3.25, "Oh Sanam...")

        # self.song_2 = Song("Rockstar", "Mohit Chauhan", 4.00, "Saada Haq...")
        # self.song_3 = Song("Kedarnath", "Amit", 5.25, "Namo Shankara...")

        def test_room_has_name(self):
            self.assertEqual("Bollywood", self.room.name)

        def test_room_has_min_capacity(self):
            self.assertEqual("3", self.room.min_capacity)

        def test_room_has_cost(self):
            self.assertEqual("10", self.room.cost)

        def test_guest_check_in_room(self):
            guest = Guest("Abhi", 20, 30)
            self.room.check_in(guest)
            self.assertEqual(1, self.guest_count())

        def test_guest_check_out_room(self):
            guest = Guest("Abhi", 20, 30)
            self.room.check_in(guest)
            self.room.check_out(guest)
            self.assertEqual(0, self.guest_count())

        def test_room_can_add_a_song(self):
            self.room.add_song(self.song_1)
            self.assertEqual(1, self.room.total_song(self.song_1))

        def test_add_waiting_list(self):
            self.room.add_to_waiting_list(self, guest)
            self.assertequal(1, self.room.waiting_list_length())
Ejemplo n.º 3
0
class TestRoom(unittest.TestCase):
    def setUp(self):
        self.room = Room("Cover Your Ears!", 15, 10)
        self.room_small = Room("Tight Squeeze", 1, 15)

        self.song = Song("Hold a chicken in the air")
        self.song_not_fav = Song("Put that chair back")

        # fav_song should be song object, not just a string
        self.guest = Guest("Sid The Sloth", 33.25, "Hold a chicken in the air")
        # like...
        # self.guest = Guest("Sid The Sloth", 33.25, song)

        # fav_song should be song object, not just a string
        self.guest_no_money = Guest("Scrooge", 3.99, "Yeah, right!")
        # like...
        # self.guest_no_money = Guest("Scrooge", 3.99, song_not_fav)

    def test_room_has_name(self):
        self.assertEqual("Cover Your Ears!", self.room.name)

    def test_room_has_capacity(self):
        self.assertEqual(15, self.room.capacity)

    def test_room_has_entry_fee(self):
        self.assertEqual(10, self.room.entry_fee)

    def test_room_start_at_0(self):
        self.assertEqual(0, self.room.guest_count())

    def test_can_check_in_guest(self):
        self.room.check_in(self.guest)
        self.assertEqual(1, self.room.guest_count())

    def test_can_find_guess_by_name(self):
        # Add guest to room
        self.room.check_in(self.guest)

        # 'Extract' guest object from room, using their name
        guest = self.room.check_out("Sid The Sloth")
        self.assertEqual("Sid The Sloth", guest.name)

    def test_song_start_at_0(self):
        self.assertEqual(0, self.room.song_count())

    def test_can_add_song(self):
        self.room.add_song(self.song)
        self.assertEqual(1, self.room.song_count())

    def test_capacity_for_more_guests(self):
        self.assertEqual(True, self.room.check_capacity())

    def test_capacity_no_more_guests(self):
        self.room_small.check_in(self.guest)
        self.assertEqual(False, self.room_small.check_capacity())

    def test_guest_has_funds(self):
        self.assertEqual(True,
                         self.room_small.confirm_guest_has_funds(self.guest))

    def test_guest_has_not_funds(self):
        self.assertEqual(
            False, self.room.confirm_guest_has_funds(self.guest_no_money))

    def test_take_fee_from_guest(self):
        # Take fee from the guest
        self.room.take_fee_from_guest(self.guest)

        # The guest should now have 10 less than before
        self.assertEqual(23.25, self.guest.money)

    def test_take_no_fee_from_guest(self):
        # Try to take fee from the guest - this ones doesn't have sufficient funds
        self.room_small.take_fee_from_guest(self.guest_no_money)

        # The guest should still have the same amount of money as before.
        self.assertEqual(3.99, self.guest_no_money.money)

    def test_for_guest_fav_song(self):
        self.room.add_song(self.song)
        self.assertEqual("Whoo!",
                         self.room.look_for_guest_fav_song(self.guest))

    def test_for_no_guest_fav_song(self):
        self.room.add_song(self.song_not_fav)
        self.assertEqual(None, self.room.look_for_guest_fav_song(self.guest))
Ejemplo n.º 4
0
class TestGuest(unittest.TestCase):
    def setUp(self):
        self.song_1 = Song(10001,
                           "Let's Make Love and Listen to Death from Above",
                           "CSS", [3, 30], 2005)
        self.song_2 = Song(10002, "Song 2", "Blur", [2, 2], 1996)
        self.song_3 = Song(10003, "E-Mail My Heart", "Britney Spears", [3, 41],
                           1999)
        self.song_4 = Song(10004, "Club Tropicana", "Wham!", [4, 28], 1983)
        self.song_5 = Song(10005, "Virtual Insanity", "Jamiroquai", [4, 4],
                           1996)

        self.guest_1 = Guest("Lovefoxxx", 36, 50, self.song_1)
        self.guest_2 = Guest("Britney Spears", 38, 100, self.song_4)
        self.guest_3 = Guest("Damon Albarn", 52, 20, self.song_3)
        self.guest_4 = Guest("Jamiroquai", 50, 5, self.song_5)
        self.guest_5 = Guest("Human Child", 8, 20, self.song_2)
        self.guest_6 = Guest("Jay-Z", 50, 10000, self.song_5)
        self.guest_7 = Guest("Shania Twain", 55, 80, self.song_1)

        self.room_1 = Room("Plush Paradise", 3)

        self.drink_1 = {"name": "Guinness", "price": 3, "alcohol_level": 3}

    def test_guest_has_name(self):
        self.assertEqual("Lovefoxxx", self.guest_1.name)

    def test_guest_has_age(self):
        self.assertEqual(38, self.guest_2.age)

    def test_guest_has_wallet(self):
        self.assertEqual(5, self.guest_4.wallet)

    def test_guest_has_favourite_song(self):
        self.assertEqual(self.song_3, self.guest_3.favourite_song)

    def test_check_song_on_playlist__song_on_playlist(self):
        big_playlist = [self.song_1, self.song_2, self.song_3, self.song_4]
        self.room_1.add_songs(big_playlist)
        self.room_1.check_in(self.guest_2)
        result = self.guest_2.check_song_on_playlist(self.room_1)
        self.assertEqual(
            f"They have {self.guest_2.favourite_song.title}! Alright!", result)

    def test_check_song_on_playlist__song_not_on_playlist(self):
        big_playlist = [self.song_1, self.song_2, self.song_3, self.song_4]
        self.room_1.add_songs(big_playlist)
        self.room_1.check_in(self.guest_6)
        result = self.guest_6.check_song_on_playlist(self.room_1)
        self.assertIsNone(result)

    def test_check_song_on_playlist__song_on_playlist_guest_not_in_room(self):
        big_playlist = [self.song_1, self.song_2, self.song_3, self.song_4]
        self.room_1.add_songs(big_playlist)
        result = self.guest_2.check_song_on_playlist(self.room_1)
        self.assertIsNone(result)

    def test_remove_cash(self):
        value = self.drink_1["price"]
        self.guest_2.remove_cash(value)
        self.assertEqual(97, self.guest_2.wallet)

    def test_increase_drunkenness(self):
        self.guest_2.increase_drunkenness(self.drink_1)
        self.guest_2.increase_drunkenness(self.drink_1)
        self.assertEqual(6, self.guest_2.drunkenness)
Ejemplo n.º 5
0
class TestRoom(unittest.TestCase):
    def setUp(self):
        self.room_1 = Room("Plush Paradise", 3)

        self.song_1 = Song(10001, "Let's Make Love and Listen to Death from Above", "CSS", [3,30], 2005)
        self.song_2 = Song(10002, "Song 2", "Blur", [2, 2], 1996)
        self.song_3 = Song(10003, "E-Mail My Heart", "Britney Spears", [3, 41], 1999)
        self.song_4 = Song(10004, "Club Tropicana", "Wham!", [4, 28], 1983)
        self.song_5 = Song(10005, "Virtual Insanity", "Jamiroquai", [4, 4], 1996)

        self.guest_1 = Guest("Lovefoxxx", 36, 50, self.song_1)
        self.guest_2 = Guest("Britney Spears", 38, 100, self.song_4)
        self.guest_3 = Guest("Damon Albarn", 52, 20, self.song_3)
        self.guest_4 = Guest("Jamiroquai", 50, 5, self.song_5)
        self.guest_5 = Guest("Human Child", 8, 20, self.song_2)
        self.guest_6 = Guest("Jay-Z", 50, 10000, self.song_5)
        self.guest_7 = Guest("Shania Twain", 55, 80, self.song_1)

        drink_1 = Drink("Guinness", 3, 3)
        drink_2 = Drink("Whiskey Sour", 6, 5)
        drink_3 = Drink("Tsingtao", 4, 3)
        
        drinks_list = [drink_1, drink_2, drink_3]

        self.bar_1 = Bar(500, drinks_list)

        
    def test_room_has_name(self):
        self.assertEqual("Plush Paradise", self.room_1.name)

    def test_room_has_capacity(self):
        self.assertEqual(3, self.room_1.capacity)

    def test_check_in__below_capacity(self):
        self.room_1.check_in(self.guest_1)
        self.room_1.check_in(self.guest_2)
        self.assertEqual([self.guest_1, self.guest_2], self.room_1.guests)

    # def test_check_in__below_capacity_and_has_exact_money(self):
    #     self.room_1.check_in(self.guest_3)
    #     self.assertEqual([self.guest_3], self.room_1.guests)

    # def test_check_in__below_capacity_and_doesnt_have_enough_money(self):
    #     self.room_1.check_in(self.guest_2)
    #     self.room_1.check_in(self.guest_4)
    #     self.assertEqual([self.guest_2], self.room_1.guests)

    def test_check_in__at_capacity(self):
        self.room_1.check_in(self.guest_1)
        self.room_1.check_in(self.guest_2)
        self.room_1.check_in(self.guest_3)
        self.room_1.check_in(self.guest_6)
        self.room_1.check_in(self.guest_7)
        self.assertEqual([self.guest_1, self.guest_2, self.guest_3], self.room_1.guests)

    def test_check_out(self):
        self.room_1.check_in(self.guest_3)
        self.room_1.check_in(self.guest_6)
        self.room_1.check_out(self.guest_3)
        self.assertEqual([self.guest_6], self.room_1.guests)

    def test_add_songs__list(self):
        computer_songs_playlist = [self.song_1, self.song_3]
        self.room_1.add_songs(computer_songs_playlist)
        self.assertEqual([self.song_1, self.song_3], self.room_1.songs)

    def test_add_songs__single_song(self):
        self.room_1.add_songs(self.song_4)
        self.assertEqual([self.song_4], self.room_1.songs)

    def test_add_songs__both(self):
        computer_songs_playlist = [self.song_1, self.song_3]
        self.room_1.add_songs(computer_songs_playlist)
        self.room_1.add_songs(self.song_4)
        self.assertEqual([self.song_1, self.song_3, self.song_4], self.room_1.songs)

    def test_add_songs__not_song(self):
        self.room_1.add_songs("cool song")
        self.assertEqual([], self.room_1.songs)

    def test_tabs_start_at_zero(self):
        self.assertEqual(self.room_1.tabs, [])

    def test_check_in_changes_tab(self):
        self.room_1.check_in(self.guest_1)
        self.room_1.check_in(self.guest_2)
        self.assertEqual(len(self.room_1.tabs), 2)
        self.assertIsInstance(self.room_1.tabs[0], Tab)
Ejemplo n.º 6
0
class TestRoom(unittest.TestCase):
    def setUp(self):
        self.room_1 =  Room("Yellow Submarine", 8, 50)
        self.room_2 =  Room("Purple Rain", 10, 60)
        self.room_3 =  Room("Blue Monday", 12, 70)
        self.room_4 =  Room("Black and White Town", 15, 80)
        self.room_5 =  Room("Pink Cadillac", 20, 90)
        self.room_6 =  Room("99 Red Baloons", 22, 100)
        
        self.guest_1 = Guest("Eddie Vedder", "Black", 500)         
        self.guest_2 = Guest("Kurt Cobain", "Teen Spirit", 300)
        self.guest_3 = Guest("Billy Corgan", "1979", 500)         
        self.guest_4 = Guest("Chris Cornell", "The Day I Tried To Live", 385)
        self.guest_5 = Guest("Zack De la Rocha", "Testify", 500)         
        self.guest_6 = Guest("Chino Moreno", "Change In the House of Flies", 350)
        self.guest_7 = Guest("Shirley Manson", "Only Happy When it Rains", 500)         
        self.guest_8 = Guest("PJ Harvey", "This is Love", 300)

        self.song_1 = Song("Tether", "Chvrches", "Synth Pop")
        self.song_2 = Song("Questions and Answers", "Biffy Clyro", "Alt Rock")
        self.song_3 = Song("The Wrong Car", "The Twilight Sad", "Post Punk")
        self.song_4 = Song("Fast Blood", "Frightened Rabbit", "Indie Folk")
        self.song_5 = Song("Scottish Fiction", "Idlewild", "Indie")


#    @unittest.skip("Delete this line to run the test")
    def test_room_name(self):
        self.assertEqual("Yellow Submarine", self.room_1.name)

#    @unittest.skip("Delete this line to run the test")
    def test_check_in(self):
        self.room_1.check_in(self.guest_1.name)
        self.assertEqual(1, len(self.room_1.guests))

#    @unittest.skip("Delete this line to run the test")
    def test_check_out(self):
        self.room_1.check_in(self.guest_1.name)
        self.room_1.check_in(self.guest_2.name)
        self.room_1.check_out(self.guest_1.name)
        self.assertEqual(1, len(self.room_1.guests))

#    @unittest.skip("Delete this line to run the test")
    def test_add_song(self):
        self.room_1.add_song(self.song_1.title, self.song_1.artist, self.song_1.genre)
        self.room_1.add_song(self.song_2.title, self.song_2.artist, self.song_2.genre)
        self.assertEqual(2, len(self.room_1.playlist))

#    @unittest.skip("Delete this line to run the test")
    def test_room_at_capacity(self):
        self.room_1.check_in(self.guest_1.name)
        self.room_1.check_in(self.guest_2.name)
        self.room_1.check_in(self.guest_3.name)
        self.room_1.check_in(self.guest_4.name)
        self.room_1.check_in(self.guest_5.name)
        self.room_1.check_in(self.guest_6.name)
        self.room_1.check_in(self.guest_7.name)
        self.room_1.check_in(self.guest_8.name)
        self.assertEqual("Sorry, you can't go in to that room, it's full.", self.room_1.room_at_capacity())

#     @unittest.skip("Delete this line to run the test")
    def test_charge_for_share_of_room(self):
        self.room_1.check_in(self.guest_1)
        self.room_1.check_in(self.guest_2)
        self.room_1.check_in(self.guest_3)
        self.room_1.check_in(self.guest_4)
        self.room_1.charge_for_share_of_room(self.guest_1)
        self.assertEqual(487.5, self.guest_1.wallet)

#    @unittest.skip("Delete this line to run the test")
    def test_search_for_song(self):
        self.room_1.add_song(self.song_1.title, self.song_1.artist, self.song_1.genre)
        self.room_1.add_song(self.song_2.title, self.song_2.artist, self.song_2.genre)
        self.room_1.add_song(self.song_3.title, self.song_1.artist, self.song_1.genre)
        self.room_1.add_song(self.song_4.title, self.song_2.artist, self.song_2.genre)
        self.room_1.add_song(self.song_5.title, self.song_2.artist, self.song_2.genre)
        self.room_1.playlist = [self.song_1, self.song_2, self.song_3, self.song_4, self.song_5]
        found_track = self.room_1.search_for_song("The Wrong Car")
        self.assertEqual("The Wrong Car", found_track)