コード例 #1
0
 def test_after_checkout_guest_appears_checkedout(self, names, num):
     assume(len(names) < num)
     hotel = Hotel(num)
     for n in names:
         hotel.checkin(n)
     for n in names:
         hotel.checkout(n)
         assert not hotel.is_checkedin(n)
コード例 #2
0
 def test_checkout_of_not_checkedin_guest(self, names1, names2, num):
     assume(len(names1) < num)
     assume(not (names1 & names2))
     hotel = Hotel(num)
     for n in names1:
         hotel.checkin(n)
     for n in names2:
         hotel.checkout(n)
コード例 #3
0
 def test_guests_with_unique_name_can_be_checkedin(self, names, num):
     assume(len(names) < num)
     hotel = Hotel(num)
     for n in names:
         hotel.checkin(n)
     for n in names:
         hotel.checkout(n)
     for n in names:
         hotel.checkin(n)
コード例 #4
0
 def test_after_checkout_guest_doesnot_have_room(self, names, num):
     assume(len(names) < num)
     hotel = Hotel(num)
     for n in names:
         hotel.checkin(n)
     for n in names:
         hotel.checkout(n)
         with pytest.raises(ValueError):
             assert hotel.room_of(n)
コード例 #5
0
 def test_checkout_of_checkedin_guest(self, names, num):
     assume(len(names) < num)
     hotel = Hotel(num)
     for n in names:
         hotel.checkin(n)
     for n in names:
         hotel.checkout(n)
     for n in names:
         assert not hotel.is_checkedin(n)
コード例 #6
0
 def test_first_key_of_keycard_is_same_as_the_second_key_of_previous_card(
         self, names1, names2, num):
     assume(len(names1) == num)
     assume(not names1 & names2)
     hotel = Hotel(num)
     room2keycard = {}
     for n in names1:
         g = hotel.checkin(n)
         room2keycard[g.room_number] = g.keycard
     for n1, n2 in zip(names1, names2):
         hotel.checkout(n1)
         g = hotel.checkin(n2)
         assert g.keycard.first_key == \
             room2keycard[hotel.room_of(g.guest_name).room_number].second_key
コード例 #7
0
 def test_assigned_room_cannot_be_opened_with_old_keycard(
         self, names1, names2, num):
     assume(len(names1) == num)
     assume(not names1 & names2)
     hotel = Hotel(num)
     room2keycard = {}
     for n in names1:
         g = hotel.checkin(n)
         room2keycard[g.room_number] = g.keycard
         # without this line, unused keycard can render the lock
         # unlockable to subsequent keycards
         hotel.room_of(n).lock.can_be_unlocked(g.keycard)
     for n1, n2 in zip(names1, names2):
         hotel.checkout(n1)
         g = hotel.checkin(n2)
         room = hotel.room_of(n2)
         assert room.lock.can_be_unlocked(g.keycard)
         assert not room.lock.can_be_unlocked(room2keycard[room.room_number])
         room2keycard[g.room_number] = g.keycard
コード例 #8
0
 def test_two_checkedin_guests_are_not_assigned_the_same_room2(
         self, names1, names2, num):
     assume(len(names2 | names1) <= num)
     assume(names1 & names2)
     hotel = Hotel(num)
     name2guest = {}
     for n in names1:
         name2guest[n] = hotel.checkin(n)
     for n1 in names2:
         if n1 in names1:
             hotel.checkout(n1)
             name2guest.pop(n1)
         else:
             g1 = hotel.checkin(n1)
             for n2 in name2guest:
                 assert name2guest[n2].room_number != \
                     g1.room_number
                 assert hotel.room_of(n2) != \
                     hotel.room_of(g1.guest_name)
             name2guest[n1] = g1
コード例 #9
0
 def test_is_checkedin_returns_false_when_not_checkedin(self):
     hotel = Hotel(10)
     guest = hotel.checkin("John")
     hotel.checkout("John")
     assert not guest.is_checkedin(hotel)