# Testing Scenarios for Airline Model

**URL:** <https://forum.canton.network/t/testing-scenarios-for-airline-model/5053>\
**Category:** App Development\
**Created:** [August 9, 2022, 11:13am UTC](https://forum.canton.network/t/testing-scenarios-for-airline-model/5053 "2022-08-09T11:13:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zerum](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/zerum/32/4713_2.png) [@Zerum](https://forum.canton.network/u/Zerum)\
**Post date:** [August 9, 2022, 11:13am UTC](https://forum.canton.network/t/testing-scenarios-for-airline-model/5053/1 "2022-08-09T11:13:30Z")

</div>

Hi,

I am learning DAML and I want to ask something related to Airline Model.

I want to ask about this test script or if you can explain 2 or 4 testing scenarios for this Model.

dajet = script do  
da ← allocateParty “DA”  
passengers@[p1, p2, p3, p4, p5]  
 ← mapA allocateParty [“P1”, “P2”, “P3”, “P4”, “P5”]  
let  
flightNumber = “DA Force One”  
classes = [Coach, Coach, Business, Business, First]  
seatClasses = TM.fromList  
[ (“1A”, First)  
, (“1B”, First)  
, (“2A”, Business)  
, (“2B”, Business)  
, (“3A”, Coach)  
, (“3B”, Coach) ]  
tickets = map  
((seq, passenger, ticketClass) →   
Ticket with  
ticketClass  
ticketRef = show seq  
flightNumber  
airline = da  
passenger  
seatChoice = ticketClass \> Coach  
)  
(zip3 [1…5] passengers classes)  
(inviteCids, flightCid) ← submit da do  
inviteCids ← mapA (\ticket → createCmd FlightInvite with ticket) tickets  
flightCid ← createCmd Flight with  
seatClasses  
allocation = TM.empty  
flightNumber  
airline = da  
invitedPassengers = passengers  
passengers =   
return (inviteCids, flightCid)

---

<div class="post-metadata">

**Author:** ![Gary\_Verhaegen](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/gary_verhaegen/32/81_2.png) [@Gary\_Verhaegen](https://forum.canton.network/u/Gary_Verhaegen)\
**Post date:** [August 9, 2022, 11:19am UTC](https://forum.canton.network/t/testing-scenarios-for-airline-model/5053/2 "2022-08-09T11:19:40Z")

</div>

Please provide code samples in-between triple-ticks (```), otherwise it’s impossible to read.

---

<div class="post-metadata">

**Author:** ![Zerum](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/zerum/32/4713_2.png) [@Zerum](https://forum.canton.network/u/Zerum)\
**Post date:** [August 9, 2022, 11:27am UTC](https://forum.canton.network/t/testing-scenarios-for-airline-model/5053/3 "2022-08-09T11:27:48Z")

</div>

(dajet = script do  
da ← allocateParty “DA”  
passengers@[p1, p2, p3, p4, p5]  
 ← mapA allocateParty [“P1”, “P2”, “P3”, “P4”, “P5”]  
let  
flightNumber = “DA Force One”  
classes = [Coach, Coach, Business, Business, First]  
seatClasses = TM.fromList  
[ (“1A”, First)  
, (“1B”, First)  
, (“2A”, Business)  
, (“2B”, Business)  
, (“3A”, Coach)  
, (“3B”, Coach) ]  
tickets = map  
((seq, passenger, ticketClass) →   
Ticket with  
ticketClass  
ticketRef = show seq  
flightNumber  
airline = da  
passenger  
seatChoice = ticketClass \> Coach  
)  
(zip3 [1…5] passengers classes)

(inviteCids, flightCid) ← submit da do  
inviteCids ← mapA (\ticket → createCmd FlightInvite with ticket) tickets  
flightCid ← createCmd Flight with  
seatClasses  
allocation = TM.empty  
flightNumber  
airline = da  
invitedPassengers = passengers  
passengers =   
return (inviteCids, flightCid)

---

<div class="post-metadata">

**Author:** ![a\_putkov](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/a_putkov/32/2971_2.png) [@a\_putkov](https://forum.canton.network/u/a_putkov)\
**Post date:** [August 9, 2022, 1:38pm UTC](https://forum.canton.network/t/testing-scenarios-for-airline-model/5053/4 "2022-08-09T13:38:09Z")

</div>

@Zerum  
As far as I can see the code snippet you included is taken from [ex-models/Airline.daml at ca6818c10923360f7158e03a4c50dabe156f5419 · digital-asset/ex-models · GitHub](https://github.com/digital-asset/ex-models/blob/ca6818c10923360f7158e03a4c50dabe156f5419/airline/daml/Airline.daml)  
Do you have some specific questions about this code?  
The fragment of the Daml script that you included performs the following actions:

1. Allocates a party named “DA”, which acts as a flight operator, and 5 parties named “P1” … “P5”, which represent 5 passengers.
2. It maps seat numbers to travel classes.
3. It iterates over the list of passengers and for each passenger creates a Ticket record (note, this is a Ticket record, not a Ticket contract).
4. For each Ticker record created in the previous step the script creates a FlightInvite contract. And it also creates a Flight contract with the list of invited passenger and an empty allocation of passengers to seats.

The rest of the script, which you did not include, iterates over the list of passengers and for each passenger exercises Accept\_Invite choice on the passenger’s FlightInvite contract, which creates a list of Ticket contracts (one Ticket contract for each passenger). The script then does a bunch of submitMustFail tests (e.g. it checks that passenger p1 cannot check in for the flight with the seat “1A” because “1A” is a First Class seat and passenger p1’s ticket is in Coach). And finally the script exercises CheckIn choice on the Ticket contract for each passenger party with correct seat, which then allows TakeOff choice to be exercised on the Flight contract (since all passengers have checked in and been allocated to their seats).  
This is a rather high level description of what the script does. I appreciate you may have further questions. If you do, please don’t hesitate to post them here.
