class TestRoom(unittest.TestCase):
    def setUp(self):
        self.song_1 = Song("Senorita-Camila cabelle")
        self.song_2 = Song("Dance Monkey")
        self.song_3 = Song("Someone you loved")
        self.song_4 = Song("Memories-Maroon 5")
        self.song_5 = Song("Shape of you")
        self.room = Room("The CodeClan Caraoke", 900.00, 20.00)

    def test_room_has_name(self):
        self.assertEqual("The CodeClan Caraoke", self.room.name)

    def test_room_has_till(self):
        self.assertEqual(900.00, self.room.till)

    def test_room_can_add_song(self):
        self.room.add_songs(self.song_1)
        self.assertEqual(1, self.room.songs_count())

    def test_can_check_in_guest(self):
        guest = Guest("Mishti", 400.00)
        self.room.check_in(guest)
        self.assertEqual(1, self.room.guest_count())

    def test_can_check_out_guest(self):
        guest = Guest("Mishti", 400.00)
        self.room.check_in(guest)
        self.room.check_out(guest)
        self.assertEqual(0, self.room.guest_count())

    def test_number_of_space(self):
        self.assertEqual(5, self.room.number_of_spaces)

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

    def test_room_has_one_guest(self):
        self.room.check_in_increase_amount(self.room)
        self.assertEqual(920.00, self.room.till)
class TestRoom(unittest.TestCase):
    def setUp(self):
        self.room = Room("Rock", [], 4.99)

    def test_room_has_music_type(self):
        self.assertEqual("Rock", self.room.music_type)

    def test_room_has_guest_list(self):
        self.assertEqual([], self.room.guest_list)

    def test_check_in(self):
        guest_1 = Guest("John", 60, 200, "Kashmir")
        guest_2 = Guest("Susan", 44, 100, "Layla")
        guest_3 = Guest("Mark", 25, 400, "Tears in Heaven")
        guest_4 = Guest("Alan", 34, 1100, "Poor Boy Blues")
        guest_5 = Guest("Alan", 17, 1100, "Africa")
        guest_6 = Guest("Mike", 60, 200, "Lay down Sally")
        guest_7 = Guest("Alex", 44, 100, "Black Moon")
        guest_8 = Guest("David", 25, 400, "Beat It")
        guest_9 = Guest("Ally", 34, 1100, "Tush")
        guest_10 = Guest("Anne", 17, 1100, "Cocaine")
        guest_11 = Guest("Jim", 60, 200, "Mean Bone")
        guest_12 = Guest("Barry", 44, 100, "Red, red wine")
        guest_13 = Guest("Charlie", 25, 400, "One")
        guest_14 = Guest("Dan", 34, 1100, "Master of Puppets")
        guest_15 = Guest("Frank", 17, 1100, "Vultures")
        guests = (guest_1, guest_2, guest_3, guest_4, guest_5, guest_6,
                  guest_7, guest_8, guest_9, guest_10, guest_11, guest_12,
                  guest_13, guest_14, guest_15)
        self.room.check_in(guests)
        self.room.charge_guest(self.room.guest_list)
        self.assertEqual(10, len(self.room.guest_list))
        self.assertEqual(49.9, round(self.room.room_revenue, 2))

    def test_check_out(self):
        guest_1 = Guest("John", 60, 200, "Kashmir")
        guest_2 = Guest("Susan", 44, 100, "Layla")
        guests = (guest_1, guest_2)
        self.room.check_out(guests)
        self.assertEqual(2, len(self.room.guest_list))

    def test_room_has_songs_list(self):
        self.assertEqual([], self.room.songs_list)

    def test_add_songs(self):
        song_1 = Song("Legs", "ZZ Top", "Rock")
        song_2 = Song("Eric Clapton", "Cocaine", "Blues")
        song_3 = Song("Stevie Ray Vaughan", "Change It", "Blues")
        song_4 = Song("BB King", "Rock Me Baby", "Blues")
        song_5 = Song("Slash", "Mean Bone", "Rock")
        song_6 = Song("Led Zeppelin", "Kashmir", "Rock")
        songs = [song_1, song_2, song_3, song_4, song_5, song_6]
        self.room.add_songs(songs)
        self.assertEqual(3, len(self.room.songs_list))

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

    def test_charge_guest(self):
        guest_1 = Guest("John", 60, 200, "Kashmir")
        guests = [guest_1]
        self.room.charge_guest(guests)
        self.assertEqual(4.99, self.room.room_revenue)

    def test_check_if_favourtite_song_in_room(self):
        song_1 = Song("Legs", "ZZ Top", "Rock")
        song_2 = Song("Eric Clapton", "Cocaine", "Blues")
        song_3 = Song("Stevie Ray Vaughan", "Change It", "Blues")
        song_4 = Song("BB King", "Rock Me Baby", "Blues")
        song_5 = Song("Slash", "Mean Bone", "Rock")
        song_6 = Song("Kashmir", "Kashmir", "Rock")
        songs = [song_1, song_2, song_3, song_4, song_5, song_6]
        self.room.add_songs(songs)
        guest = Guest("John", 60, 200, "Kashmir")
        self.assertEqual(3, len(self.room.songs_list))
        # for song in self.room.songs_list:
        #     print(song.title)
        self.assertEqual("Whoo!",
                         self.room.check_if_favourite_song_in_room(guest))
Ejemplo n.º 3
0
class TestRoom(unittest.TestCase):
    def setUp(self):
        self.room = Room("The Wonderland", 90, 400, 0)

        self.guest_1 = Guest("Cyril", "Yes!", "VIP", 30000, "Dddudu")
        self.guest_2 = Guest("Max", "Yayy", "Regular", 400, "Perfect")
        self.guest_3 = Guest("David", "Grmm", "VIP", 300, "See you again")
        self.guest_4 = Guest("Daniel", "Whoop", "VIP", 8000, "Gucci")

        self.song_1 = Song("Dddudu", "Blackpink")
        self.song_2 = Song("Perfect", "Ed sheeran")
        self.song_3 = Song("Gucci", "Jessie")

        red_wine = Bar("Red Wine", 300)
        jack_daniels = Bar("Jack Daniels", 200)
        johnny_walker = Bar("Johnny Walker", 400)
        water = Bar("Water", 10)

        self.vip_drinks = [{
            "Drink": red_wine,
            "quantity": 9
        }, {
            "Drink": jack_daniels,
            "quantity": 4
        }, {
            "Drink": johnny_walker,
            "quantity": 5
        }, {
            "Drink": water,
            "quantity": 50
        }]

    def test_name_of_room(self):
        self.assertEqual("The Wonderland", self.room.name)

    def test_room_has_fee(self):
        self.assertEqual(400, self.room.vip_fee)

    def test_room_fee(self):
        self.assertEqual(0, self.room.till)

    def test_guest_sorted(self):
        self.room.add_guest(self.guest_1)
        self.room.add_guest(self.guest_1)
        self.room.add_guest(self.guest_2)
        self.room.add_guest(self.guest_2)
        self.assertEqual(2, len(self.room.vip_guest))
        self.assertEqual(2, len(self.room.regular_guest))

    def test_checkout_guest(self):
        self.room.add_guest(self.guest_1)
        self.room.add_guest(self.guest_1)
        self.room.add_guest(self.guest_1)
        self.room.check_out_guest(self.guest_1)
        self.room.add_guest(self.guest_2)
        self.room.add_guest(self.guest_2)
        self.room.check_out_guest(self.guest_2)
        self.assertEqual(2, len(self.room.vip_guest))
        self.assertEqual(1, len(self.room.regular_guest))

    def test_song_added_to_list(self):
        self.room.add_songs(self.song_1)
        self.room.add_songs(self.song_2)
        self.assertEqual(2, len(self.room.songs))

    def test_minimize_number_of_guests(self):
        self.room.add_guest(self.guest_1)
        self.room.add_guest(self.guest_1)
        self.room.add_guest(self.guest_1)
        self.room.add_guest(self.guest_1)
        self.room.add_guest(self.guest_1)
        self.room.add_guest(self.guest_1)
        self.room.add_guest(self.guest_1)
        self.room.add_guest(self.guest_1)
        self.room.restrict_guest(self.guest_1)
        self.assertEqual(8, len(self.room.vip_guest))
        self.assertEqual(3, self.room.waiting_line)

    def test_minimize_number_of_regular_guests(self):
        self.room.add_guest(self.guest_2)
        self.room.add_guest(self.guest_2)
        self.room.add_guest(self.guest_2)
        self.room.add_guest(self.guest_2)
        self.room.add_guest(self.guest_2)
        self.room.add_guest(self.guest_2)
        self.room.restrict_guest(self.guest_2)
        self.assertEqual(1, self.room.waiting_line)

    def test_room_till(self):
        self.guest_1.pay_fee(self.room)
        self.guest_2.pay_fee(self.room)
        self.assertEqual(490, self.room.till)

    def test_guest_cant_afford(self):
        self.room.guest_can_afford(self.guest_3)
        self.assertEqual(0, self.room.till)

    def test_guest_can_afford(self):
        self.room.guest_can_afford(self.guest_1)
        self.assertEqual(400, self.room.till)

    def test_guest_can_find_song_by_artist(self):
        self.room.add_songs(self.song_1)
        self.room.add_songs(self.song_2)
        self.assertEqual("Perfect",
                         self.room.guest_can_find_song(self.song_2.artist))

    def test_guest_favourite_song(self):
        self.room.add_songs(self.song_1)
        self.room.add_songs(self.song_2)
        self.room.add_songs(self.song_3)
        self.assertEqual("Yes!", self.room.play_song(self.guest_1))
        self.assertEqual("Nahhh", self.room.play_song(self.guest_3))

    def test_pub_add_drink(self):
        self.room.add_drink(self.vip_drinks[1])
        self.room.add_drink(self.vip_drinks[1])
        self.assertEqual(6, self.vip_drinks[1]["quantity"])

    def test_pub_remove_drink(self):
        self.room.add_drink(self.vip_drinks[2])
        self.room.add_drink(self.vip_drinks[2])
        self.room.remove_drink(self.vip_drinks[2])
        self.assertEqual(6, self.vip_drinks[2]["quantity"])

    def test_guest_sell_drink(self):
        self.guest_4.pay_fee(self.room)
        self.room.sell_drink(self.guest_4, self.vip_drinks[1])
        self.room.add_songs(self.song_3)
        self.assertEqual(600, self.room.till)
        self.assertEqual(3, self.vip_drinks[1]["quantity"])
        self.assertEqual(7400, self.guest_4.wallet)
        self.assertEqual("Whoop", self.room.play_song(self.guest_4))