Ejemplo n.º 1
0
class TestGuest(unittest.TestCase):
    def setUp(self):
        self.guest_1 = Guest("Pierre", 50, "Gotta Go")
        self.guest_2 = Guest("Alexander", 40, "On My Radio")
        self.guest_3 = Guest("Pepe", 30, "Divorce a I'ltalienne")
        self.guest_4 = Guest("Edi", 5, "Gotta Go")

        self.room_1 = Room("Bongo", 3, 20)
        self.room_2 = Room("Studio 24", 5, 30)

        self.song_1 = Song("Gotta Go", "Agnostic Front", 3.2)
        self.song_2 = Song("On My Radio", "Selecter", 3.52)
        self.song_3 = Song("Divorce a I'ltalienne", "Mungo's Hifi", 3.46)

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

    def test_guest_has_money(self):
        self.assertEqual(30, self.guest_3.cash)

    def test_guest_paying_entry_decreases_cash(self):
        self.guest_1.pay_entry_fee(self.guest_1, self.room_1)
        self.assertEqual(30, self.guest_1.cash)

    def test_if_guest_fav_song_is_in_room(self):
        self.room_1.add_song_to_list(self.song_1, self.room_1)
        self.room_1.add_song_to_list(self.song_2, self.room_1)
        self.assertEqual(
            "Whoo!", self.guest_1.fav_song_in_room(self.guest_1, self.room_1))
Ejemplo n.º 2
0
class TestRoom(unittest.TestCase):
    def setUp(self):
        self.room_1 = Room("Pink_room", 30, 400.00)
        self.room_2 = Room("Blue_room", 15, 200.00)
        self.song_1 = Song("Halo", "Beyonce")
        self.song_2 = Song("Living la vida loca", "Ricky Martin")
        self.guest = Guest("Superman", 600, "Bootilicious")
        self.guest2 = Guest("Mariah", 750, "All I want for Christmas")

    def test_room_has_name(self):
        self.assertEqual("Pink_room", self.room_1.room_name)

    def test_check_room_capacity(self):
        self.assertEqual(30, self.room_1.capacity)

    def test_set_room_rate(self):
        self.assertEqual(400, self.room_1.rate["large"])
        self.assertEqual(200, self.room_2.rate["small"])

    def test_room_has_a_till(self):
        self.assertEqual(150, self.room_1.till)

    def test_room_has_song_list(self):
        self.assertEqual([], self.room_1.song_list)

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

    def test_room_can_add_to_song_list(self):
        self.room_1.add_song_to_list(self.song_1)
        self.assertEqual(1, len(self.room_1.song_list))

    def test_room_can_add_to_guestlist(self):
        self.room_1.add_to_guestlist(self.guest)
        self.assertEqual(1, len(self.room_1.guest_list))

    def test_room_can_add_to_guestlist_if_capacity(self):
        self.room_1.add_to_guestlist_if_capacity(self.guest)
        self.room_1.add_to_guestlist_if_capacity(self.guest2)
        self.assertEqual(2, len(self.room_1.guest_list))

    def test_room_can_remove_from_guestlist(self):
        self.room_1.add_to_guestlist(self.guest)
        self.room_1.remove_from_guestlist(self.guest)
        self.assertEqual(0, len(self.room_1.guest_list))

    def test_charge_guest_for_room(self):
        self.room_1.add_to_till(self.guest)
        self.assertEqual(550, self.room_1.till)
        self.assertEqual(200, self.guest.cash_amount)
Ejemplo n.º 3
0
class TestRoom(unittest.TestCase):
    def setUp(self):
        self.room_1 = Room("CBGB", 25.00)
        self.song_1 = Song("Juice", "Lizzo")
        self.song_2 = Song("Dr Dre", "Forgot About Dre")
        self.song_3 = Song("David Byrne", "Finite=Alright")
        self.song_4 = Song("Portishead", "Glory Box")
        self.guest_1 = Guest("Mick", "Jagger", 20, 12000.00, "Gimme Shelter")
        self.guest_2 = Guest("Justin", "Bieber", 16, 0.82, "Sorry")
        self.guest_3 = Guest("Joni", "Mitchell", 21, 100.00, "Juice")
        self.guest_4 = Guest("Susan", "Boyle", 47, 36.42, "F**k tha Police")
        self.guest_5 = Guest("Courtney", "Love", 31, 666.66,
                             "Getting Away With It")

    def test_room_has_name(self):
        self.assertEqual("CBGB", self.room_1.get_room_name())

    def test_room_name_change(self):
        self.room_1.change_room_name("Bongo Club")
        self.assertEqual("Bongo Club", self.room_1.get_room_name())

    def test_room_has_song_list(self):
        self.assertEqual([], self.room_1.get_song_list())

    def test_song_present_in_list(self):
        self.song_present_in_list()
        self.assertEqual(True, self.room_1.song_present_in_list())

    def test_initial_song_list_count_is_zero(self):
        self.room_1.song_count()
        self.assertEqual(0, self.room_1.song_count())

    def test_add_song_to_list(self):
        self.room_1.add_song_to_list(self.song_3)
        self.assertEqual(1, self.room_1.song_count())

    def test_add_song_to_list__multiple_songs(self):
        self.room_1.add_song_to_list(self.song_3)
        self.room_1.add_song_to_list(self.song_2)
        self.room_1.add_song_to_list(self.song_1)
        self.assertEqual(3, self.room_1.song_count())

    def test_remove_song_from_list(self):
        self.room_1.song_list = [
            self.song_1, self.song_3, self.song_2, self.song_4
        ]
        self.room_1.remove_song_from_list(self.song_4)
        self.assertEqual(3, self.room_1.song_count())

    def test_remove_song_from_list__multiple(self):
        self.room_1.song_list = [
            self.song_1, self.song_3, self.song_2, self.song_4
        ]
        self.room_1.remove_song_from_list(self.song_1)
        self.room_1.remove_song_from_list(self.song_2)
        self.room_1.remove_song_from_list(self.song_4)
        self.assertEqual(1, self.room_1.song_count())

    def test_clear_song_list(self):
        self.room_1.clear_song_list()
        self.assertEqual(0, self.room_1.song_count())

    def test_room_has_guest_list(self):
        self.assertEqual([], self.room_1.get_guest_list())

    def test_check_in_guest(self):
        self.room_1.check_in_guest(self.guest_1)
        self.assertEqual(1, self.room_1.guest_count())

    def test_check_in_guest__multiple(self):
        self.room_1.check_in_guest(self.guest_1)
        self.room_1.check_in_guest(self.guest_3)
        self.room_1.check_in_guest(self.guest_4)
        self.assertEqual(3, self.room_1.guest_count())

    def test_check_in_room_full(self):
        self.room_1.guest_list = [
            self.guest_1, self.guest_3, self.guest_2, self.guest_4
        ]
        self.room_1.check_in_guest(self.guest_5)
        self.assertEqual("GO AWAY COURTNEY, YOU KILLED KURT!!!",
                         self.room_1.check_in_guest(self.guest_5))
        self.assertEqual(4, self.room_1.guest_count())

    def test_check_out_guest(self):
        self.room_1.guest_list = [
            self.guest_1, self.guest_3, self.guest_2, self.guest_4
        ]
        self.room_1.check_out_guest(self.guest_2)
        self.assertEqual(3, self.room_1.guest_count())

    def test_check_out_guest__multiple(self):
        self.room_1.guest_list = [
            self.guest_1, self.guest_3, self.guest_2, self.guest_4
        ]
        self.room_1.check_out_guest(self.guest_2)
        self.room_1.check_out_guest(self.guest_4)
        self.assertEqual(2, self.room_1.guest_count())

    def test_clear_room(self):
        self.room_1.clear_room()
        self.assertEqual(0, self.room_1.guest_count())

    def test_add_cash_to_till(self):
        self.room_1.add_cash_to_till(100)
        self.assertEqual(200, self.room_1.till_count())

    def test_charge_entry_fee(self):
        self.room_1.charge_entry_fee(self.guest_3)
        self.assertEqual(75.00, self.guest_3.wallet_cash_count())
        self.assertEqual(125.00, self.room_1.till_count())
Ejemplo n.º 4
0
class TestRoom(unittest.TestCase):
    def setUp(self):
        self.room_1 = Room("Bongo", 3, 20)
        self.room_2 = Room("Studio 24", 5, 30)

        self.guest_1 = Guest("Pierre", 50, "Gotta Go")
        self.guest_2 = Guest("Alexander", 40, "On My Radio")
        self.guest_3 = Guest("Pepe", 30, "Divorce a I'ltalienne")
        self.guest_4 = Guest("Edi", 5, "Gotta Go")

        self.song_1 = Song("Gotta Go", "Agnostic Front", 3.2)
        self.song_2 = Song("On My Radio", "Selecter", 3.52)
        self.song_3 = Song("Divorce a I'ltalienne", "Mungo's Hifi", 3.46)

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

    def test_room_has_capacity(self):
        self.assertEqual(True, isinstance(self.room_1.capacity, int))

    def test_room_entry_fee(self):
        self.assertEqual(30, self.room_2.entry_fee)

    def test_guest_list_empty(self):
        self.assertEqual([], self.room_1.guest_list)

    def test_song_list_empty(self):
        self.assertEqual([], self.room_2.song_list)

    def test_add_guest_to_list(self):
        room = self.room_1
        room.add_guest_to_room(self.guest_1, room)
        #check if guest is added to the list
        self.assertEqual(1, len(room.guest_list))
        #check if money is taken from the guest
        self.assertEqual(30, self.guest_1.cash)
        #check if money is added to the till
        self.assertEqual(120, room.check_till(room))

    def test_add_guests_to_list(self):
        room = self.room_1
        room.add_guest_to_room(self.guest_1, room)
        room.add_guest_to_room(self.guest_2, room)
        self.assertEqual(2, len(room.guest_list))

    def test_remove_guest_from_room(self):
        room = self.room_1
        room.add_guest_to_room(self.guest_1, room)
        room.remove_guest_from_room(self.guest_1, room)
        self.assertEqual([], room.guest_list)

    def test_song_to_room(self):
        self.room_1.add_song_to_list(self.song_1, self.room_1)
        self.assertEqual(1, len(self.room_1.song_list))

    def test_full_room(self):
        room = self.room_1
        room.add_guest_to_room(self.guest_1, room)
        room.add_guest_to_room(self.guest_2, room)
        room.add_guest_to_room(self.guest_3, room)
        self.assertEqual(room.capacity, len(room.guest_list))

    def test_to_many_guests_in_room(self):
        room = self.room_1
        room.add_guest_to_room(self.guest_1, room)
        room.add_guest_to_room(self.guest_2, room)
        room.add_guest_to_room(self.guest_3, room)
        self.assertEqual("Room is full, please wait outside",
                         room.add_guest_to_room(self.guest_4, room))

    def test_to_many_guests_in_room2(self):
        room = self.room_1
        room.add_guest_to_room(self.guest_1, room)
        room.add_guest_to_room(self.guest_2, room)
        room.add_guest_to_room(self.guest_3, room)
        room.add_guest_to_room(self.guest_4, room)
        self.assertEqual(room.capacity, len(room.guest_list))

    def test_check_if_guest_has_enough_money(self):
        self.assertEqual(True,
                         self.room_2.refuse_entry(self.guest_4, self.room_2))

    def test_check_if_guest_has_enough_money2(self):
        self.room_2.add_guest_to_room(self.guest_4, self.room_2)
        self.assertEqual([], self.room_1.guest_list)

    def test_check_if_guest_has_enough_money3(self):
        self.room_2.add_guest_to_room(self.guest_3, self.room_2)
        self.assertEqual(1, len(self.room_2.guest_list))

    def test_check_till(self):
        self.assertEqual(self.room_1.till, self.room_1.check_till(self.room_1))

    def test_check_if_fee_add_to_till(self):
        self.room_1.add_entry_fee_to_till(self.room_1)
        self.assertEqual(120, self.room_1.check_till(self.room_1))

    def test_if_guest_fav_song_is_in_room(self):
        self.room_1.add_song_to_list(self.song_1, self.room_1)
        self.assertEqual(
            "Whoo!", self.guest_1.fav_song_in_room(self.guest_1, self.room_1))

    def test_remove_all_from_room(self):
        room = self.room_2
        room.add_guest_to_room(self.guest_1, room)
        room.add_guest_to_room(self.guest_2, room)
        room.remove_all_from_room(room)
        self.assertEqual([], room.guest_list)
        self.assertEqual(160, room.check_till(room))

    def test_sesion_time_out_empty_room(self):
        room = self.room_1
        room.add_guest_to_room(self.guest_1, room)
        room.add_guest_to_room(self.guest_2, room)
        room.add_song_to_list(self.song_1, room)
        room.add_song_to_list(self.song_2, room)
        room.add_song_to_list(self.song_3, room)
        room.add_song_to_list(self.song_1, room)
        self.assertEqual([], room.guest_list)