Ejemplo n.º 1
0
class TestRoom(unittest.TestCase):
    def setUp(self):
        self.room = Room("Room 01")
        self.guest = Guest("Katya")
        self.guest2 = Guest("Trixie")

    @unittest.skip("Delete this line to run the test")
    def test_check_room_empty(self):
        self.assertEqual(0, self.room.check_room_occupancy())

    @unittest.skip("Delete this line to run the test")
    def test_check_room_occupancy(self):
        self.assertEqual(1, self.room.check_room_occupancy())
    
    # @unittest.skip("Delete this line to run the test")
    def test_add_guest_to_room(self):
        self.room.add_guest_to_room(self.guest)
        self.room.add_guest_to_room(self.guest2)
        self.assertEqual(2, self.room.check_room_occupancy())

    # @unittest.skip("Delete this line to run the test")
    def test_remove_guest_from_room(self):
        self.room.add_guest_to_room(self.guest)
        self.room.add_guest_to_room(self.guest2)
        self.room.remove_guest_from_room(self.guest)
        self.assertEqual(1, self.room.check_room_occupancy())

    # @unittest.skip("Delete this line to run the test")
    def test_add_song_to_room(self):
        song = Song("Reasons To Be Cheerful Part 3", "Ian Dury and The Blockheads")
        song2 = Song("Believe", "Cher")
        self.room.add_song_to_room(song)
        self.room.add_song_to_room(song2)
        self.assertEqual(2, self.room.check_room_songs())
Ejemplo n.º 2
0
class TestRoom(unittest.TestCase):
    def setUp(self):
        self.song1 = Song("Help", "The Beatles")
        self.song2 = Song("Saturday Night", "Sam Cooke")

        self.songs = [self.song1, self.song2]

        self.guest1 = Guest("Hannah")
        self.guest2 = Guest("Louise")
        self.guest3 = Guest("Harry")

        self.guests = [self.guest1, self.guest2, self.guest3]

        self.room = Room("Motown", 3)

    def test_room_has_name(self):
        self.assertEqual("Motown", self.room.get_name())

    def test_can_add_song(self):
        song = self.song2
        self.room.add_song_to_room(song)
        self.assertEqual(1, self.room.number_of_songs())

    def test_can_check_in_guest(self):
        self.room.check_in_guest(self.guest1)
        self.assertEqual(1, self.room.number_of_guests())

    def test_room_has_capacity(self):
        self.assertEqual(3, self.room.get_capacity())

    def test_can_check_guest_out(self):
        self.room.check_in_guest(self.guest3)
        self.room.check_out_guest(self.guest3)
        self.assertEqual(0, self.room.number_of_guests())
Ejemplo n.º 3
0
class TestRoom(unittest.TestCase):

    def setUp(self):
        self.room = Room("Room 1", 40, 4)
        self.guests = Guest("Rocky", 100, "Eye of the tiger")

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

    def test_room_has_price(self):
        self.assertEqual(40, self.room.price)

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

    def test_can_get_current_guests(self):
        self.room.add_guest_to_room(self.guests)
        self.assertEqual(1, self.room.get_current_guests())
    
    def test_can_add_guest_to_room(self):
        guest = Guest("Rocky", 100, "Eye of the tiger")
        self.room.guests.append(guest)
        self.assertEqual(1, self.room.get_current_guests())

    def test_can_remove_guest_from_room(self):
        guest = Guest("Rocky", 100, "Eye of the tiger")
        self.room.guests.append(guest)
        self.room.guests.remove(guest)
        self.assertEqual (0, self.room.get_current_guests())

    def test_can_remove_all_guests_from_room(self):
        guest = Guest("Rocky", 100, "Eye of the tiger")
        self.room.guests.append(guest)
        self.room.guests = []
        self.assertEqual(0, self.room.get_current_guests())

    def test_can_add_guest_to_room_room_full(self):
        guest_1 = Guest("Rocky", 100, "Eye of the tiger")
        guest_2 = Guest("Apollo", 100, "Living in America")
        guest_3 = Guest("Adrian", 100, "No easy way out")
        guest_4 = Guest("Paulie", 100, "Heart's on fire")
        guest_5 = Guest("Ivan", 100, "Burning heart")
        self.room.guests.append(guest_1)
        self.room.guests.append(guest_2)
        self.room.guests.append(guest_3)
        self.room.guests.append(guest_4)
        self.assertEqual("Room is full", self.room.add_guest_to_room(guest_5))

    def test_can_take_room_payment_from_guest(self):
        self.assertEqual(40, self.room.take_room_payment_from_guest(self.guests))

    def test_can_add_song_to_room(self):
        song = Song("Eye of the tiger")
        self.assertEqual("Eye of the tiger", self.room.add_song_to_room(song))
Ejemplo n.º 4
0
class TestRoom(unittest.TestCase):
    def setUp(self):

        self.song = Song("Clint Eastwood", "Gorrilaz", "Electropop")
        self.song2 = Song("All Eyez On Me", "Tupac", "Rap")
        self.song3 = Song("Timeless", "Il Divo", "Classical")
        self.song4 = Song("Hurt", "Johnny Cash", "Country")
        self.song5 = Song("Mustang Sally", "Wilson Pinkett", "Blues")
        self.song6 = Song("Think Twice", "Celine Dion", "Soft Rock")
        self.song7 = Song("Bye Bye", "Mariah Carey", "R&B")
        self.song8 = Song("Perfect", "Ed Sheeran", "Pop")
        self.guest = Guest("Frank Samson", 50.00, 30, self.song)
        self.room = Room("300", 30.00, 0, [self.song, self.song2])
        self.room2 = Room("301", 25.00, 1, [self.song3, self.song4])
        self.room3 = Room("302", 20.00, 1, [self.song5, self.song6])
        self.room4 = Room("303", 30.00, 0, [self.song7, self.song8])

    # 7 test room has number
    def test_room_has_number(self):
        self.assertEqual("300", self.room.number)

    # 8 test room has availability
    def test_room_has_availability(self):
        self.assertEqual(0, self.room.availability)

    # 9 test room has price
    def test_room_has_price(self):
        self.assertEqual(30, self.room.price)

    # 13 test room has playlist
    def test_room_has_playlist(self):
        self.assertEqual(2, len(self.room.playlist))

    # 15 test add songs to room
    def test_add_song_to_room(self):
        self.room.add_song_to_room(self)
        self.assertEqual([], self.room2.booking)
Ejemplo n.º 5
0
class TestRoom(unittest.TestCase):
    def setUp(self):
        self.room = Room('Smooth Room', 50.00, 3, 5.00)
        self.guest = Guest('TJ', 100.00)
        self.song = Song('Ed Sheeran - Dive')

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

    def test_check_in_guest(self):
        self.room.check_in_guest(self.guest)
        self.assertEqual(1, self.room.guest_count())

    def test_check_out_guest(self):
        self.room.check_in_guest(self.guest)
        self.room.check_out_guest(self.guest)
        self.assertEqual(0, self.room.guest_count())

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

    def test_add_song_to_room(self):
        self.room.add_song_to_room(self.song)
        self.assertEqual(1, self.room.song_count())

    def test_remove_song_from_room(self):
        self.room.add_song_to_room(self.song)
        self.room.remove_song_from_room(self.song)
        self.assertEqual(0, self.room.song_count())

    def test_check_capacity(self):
        self.room.check_in_guest(self.guest)
        self.room.check_in_guest(self.guest)
        self.room.check_in_guest(self.guest)
        self.room.check_in_guest(self.guest)
        self.assertEqual(4, self.room.guest_count())
Ejemplo n.º 6
0
class TestRoom(unittest.TestCase):

    def setUp(self):
        self.guest = Guest("John Travolta", 34, 50, "Saturday Night Fever")
        self.guest_2 = Guest("Cyndi Lauper", 50, 60, "Girls just wanna have fun")
        self.guest_3 = Guest("Bob Dylan", 20, 35, "Blowin in the wind")
        self.guest_4 = Guest("Tom Jones", 26, 80, "It's not unusual")
        self.guest_5 = Guest("Dizzee Rascal", 31, 200, "Bonkers")
        self.guest_6 = Guest("Beyonce", 19, 40, "If I were a boy")
        self.song = Song("Saturday Night Fever", "The Bee Gees", 3.22)
        self.song_2 = Song("Girls just wanna have fun", "Cyndi Lauper", 2.58)
        self.song_3 = Song("Blowin in the wind", "Bob Dylan", 4.15)
        self.song_4 = Song("It's not unusual", "Tom Jones", 3.42)
        self.song_5 = Song("Bonkers", "Dizzee Rascal", 3.12)
        self.song_6 = Song("If I were a boy", "Beyonce", 4.11)
        self.example_room_1 = Room("stars in your eyes", 5, self.guest, self.song, [], [])
        self.example_room_2 = Room("Britains Got Talent", 4, self.guest, self.song, ["John Travolta", "Cyndi Lauper"], [])
        self.example_room_3 = Room("The Voice", 4, self.guest, self.song, ["John Travolta", "Cyndi Lauper", "Dizzee Rascal", "Beyonce"], [{
            "title": "Saturday Night Fever",
            "Artist": "The Bee Gees",
            "length": 3.22,
        },
        {
            "title": "Girls just wanna have fun",
            "Artist": "Cyndi Lauper",
            "length": 2.58,
        },
        {
            "title": "Blowin in the wind",
            "Artist": "Bob Dylan",
            "length": 4.15
        }
        ])

    def test_room_has_name(self):
        self.assertEqual("stars in your eyes", self.example_room_1.name)

    def test_room_has_a_capacity(self):
        self.assertEqual(5, self.example_room_1.capacity)

    def test_room_has_a_guest(self):
        self.assertEqual("John Travolta", self.example_room_1.guest.name)

    def test_room_has_a_song(self):
        self.assertEqual("Saturday Night Fever", self.example_room_1.song.title)

    def test_room_has_a_checked_in_list(self):
        self.assertEqual(0, len(self.example_room_1.checked_in_list))

    def test_guest_can_check_into_room(self):
        self.example_room_1.check_guest_into_room(self.guest)
        self.assertEqual(1, len(self.example_room_1.checked_in_list))

    def test_guest_can_check_out_of_room(self):
        self.example_room_2.check_guest_out_of_room(self.guest)
        self.assertEqual(1, len(self.example_room_2.checked_in_list))

    def test_guest_can_check_out_of_room__name_not_in_list(self):
        self.example_room_2.check_guest_out_of_room(self.guest_3)
        self.assertEqual(2, len(self.example_room_2.checked_in_list))

    def test_room_has_a_playlist(self):
        self.assertEqual(0, len(self.example_room_1.playlist))

    def test_can_add_song_to_room(self):
        self.example_room_1.add_song_to_room(self.song)
        self.assertEqual(1, len(self.example_room_1.playlist))

    def test_guest_can_check_into_room__too_many_people(self):
        self.example_room_3.check_guest_into_room(self.guest_4)
        self.assertEqual("Sorry, maximum occupancy reached", self.example_room_3.check_guest_into_room(self.guest_4))

    def test_room_has_playlist__room_3_added_playlist(self):
        self.assertEqual(3, len(self.example_room_3.playlist))

    def test_if_favourite_song_on_playlist__yes(self):
        self.example_room_3.check_song_on_playlist(self.guest)
        self.assertEqual("Yay! They have my favourite song!", self.example_room_3.check_song_on_playlist(self.guest))

    def test_if_favourite_song_on_playlist__no(self):
        self.example_room_3.check_song_on_playlist(self.guest_6)
        self.assertEqual("Boo! They don't have my favourite song.", self.example_room_3.check_song_on_playlist(self.guest_6))