Hotel Booking Example
pytest 9.1.1 pytest-given 0.4.1
Module:
Carol picks a suite for the group
✓ passed 0ms
Given
our organizer Carol
the Deluxe Suite is listed as available
When
Carol searches for a Room
Carol selects the Deluxe Suite
Then
the Deluxe Suite is held for the group
Carol completes the booking for both guests
✓ passed 0ms
Given
our organizer Carol
our guest Alice
our guest Bob
Carol has selected the Deluxe Suite
When
Carol adds Alice and Bob to the Booking
Carol submits the Payment for the Booking
Then
the Booking System confirms the Booking
the Booking System sends the Confirmation to Alice and Bob
When
Alice and Bob check in to the Deluxe Suite
Then
both guests are checked in
Payment is declined — the booking is not finalized
✗ failed 39ms
Given
our organizer Carol
our guest Alice
our guest Bob
Carol has added Alice and Bob to the Booking
When
Carol submits the Payment by {payment_method} for the Booking
Then
the Booking System declines the Payment because of {decline_reason}
the Booking stays pending and no Confirmation is sent to Alice or Bob
payment_method decline_reason status
credit card insufficient funds ✓
debit card expired card ✓
bank transfer fraud check failed ✓
gift card partial balance ✗
assert 'unsupported payment method' == 'partial balance' - partial balance + unsupported payment method
examples/hotel-booking/test_hotel_booking.py:283: in test_payment_declined
    assert processor_response == decline_reason
E   AssertionError: assert 'unsupported payment method' == 'partial balance'
E     
E     - partial balance
E     + unsupported payment method
Alice cancels her booking and is refunded
✓ passed 0ms
Given
our guest Alice
Alice has a confirmed Booking she paid for
When
Alice cancels the Booking
Then
the Booking System refunds the Payment for the Booking
the Booking System sends a Confirmation to Alice
Alice rebooks her cancelled booking (planned feature)
⊗ expected failure 4ms
Expected to fail: rebooking is not implemented yet
Given
our guest Alice
Alice has cancelled her stay
When
Alice rebooks the Booking
rebooking a cancelled booking is not supported yet
examples/hotel-booking/test_hotel_booking.py:329: in test_rebook_cancelled_booking
    rebook_cancelled_booking(stay)
examples/hotel-booking/test_hotel_booking.py:315: in rebook_cancelled_booking
    raise NotImplementedError('rebooking a cancelled booking is not supported yet')
E   NotImplementedError: rebooking a cancelled booking is not supported yet
Alice checks in, then cancels a later booking
✓ passed 0ms
Given
our guest Alice
Alice has a confirmed Booking now and one next month
When
Alice checks in to the Deluxe Suite
Then
her current stay is checked in
When
Alice cancels her later Booking
Then
the later booking is cancelled
When
she tries to cancel the stay she has checked in to
Then
the cancellation is refused
Book a Group Trip
8 sentences4 scenarios
Carolsearches forRoom
search 1 scenario
CarolselectsDeluxe Suite
select 2 scenarios
CaroladdsAlicetoBooking
CaroladdsBobtoBooking
2 scenarios1 failing
CarolsubmitsPaymentforBooking
2 scenarios1 failing
Booking SystemconfirmsBooking
1 scenario
Booking SystemsendsConfirmationtoAlice
Booking SystemsendsConfirmationtoBob
1 scenario
Carolredeemsloyalty points
no coverage
Alicechecks in toDeluxe Suite
Bobchecks in toDeluxe Suite
2 scenarios
Scenarios
Covers:
Covers:
Covers:
Covers:
Cancel a Booking
4 sentences3 scenarios
AlicecancelsBooking
cancel 2 scenarios
Booking SystemrefundsPaymentforBooking
1 scenario
Booking SystemsendsConfirmationtoAlice
1 scenario
AlicerebooksBooking
rebook 1 scenario1 expected to fail
Scenarios
Covers:
Covers:
Covers:
Glossary
14 terms 3 actors 5 work objects 6 activities
Actors
Organizer
Person booking accommodation on behalf of a group.
1 instance1 story3 scenarios
Guest
Individual traveler in the group.
2 instances2 stories5 scenarios
Booking System
Automated reservation back-end.
2 stories3 scenarios
Work Objects
Room
A bookable hotel room.
1 instance1 story3 scenarios
Booking
A reservation for one or more rooms.
2 stories5 scenarios
Payment
Money transferred for a booking.
2 stories3 scenarios
Confirmation
Notification of a successful booking.
2 stories3 scenarios
loyalty points
Undefined
1 story
Activities
confirm
Guarantee a paid booking so its rooms are held for arrival.
1 story1 scenario
decline
Refuse a payment, leaving its booking pending.
1 scenario
cancel
Withdraw a booking before arrival.
1 story2 scenarios
refund
Return the payment for a cancelled booking.
1 story1 scenario
rebook
Restore a cancelled booking for the same rooms and dates.
1 story1 scenario
redeems
Undefined
1 story
No terms match this filter.