-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtasks.yml
315 lines (288 loc) · 8.54 KB
/
tasks.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
name: homepage
title: Enable the homepage.
description: |
Your task is to enable home page on your website.
* Fork the repository https://github.com/pipalacademy/rajdhani
* Enable actions on your repo by visitng the Actions tab of your repo
* Enable the home page on your website by setting the feature flag `flag_homepage = True`
in the `rajdhani/config.py`.
Once you commit and push your changes, your website will be updated.
checks:
- check_flag:
flag: flag_homepage
- check_webpage_content:
url: /
expected_text: "<h2>Search Trains</h2>"
---
name: search-trains
title: Find trains on search
description: |
The `search_trains` functions in the db module is called
to find the matching trains from source station to destination
when the user searches for trains. Currently, that function
returns a placeholder result. Replace that with the correct
implementation.
For this task, you just need to focus on the `from_station` and
`to_station` of the train and no need to support for the
intermediate stations.
File: `rajdhani/db.py`<br>
Function: `search_trains`
checks:
- check_search_trains:
from_station: SBC
to_station: MAS
expected_trains:
- 12028
- 12608
- 12640
- 12658
- 12610
---
name: search-trains-with-ticketclass
title: Support ticket class in train search
description: |
Enable ticket class fields in the search form by setting
`flag_ticketclass_in_search` in `config.py` to `True`.
Update the `search_trains` function to consider only the trains
that has that ticket class.
Note: The `ticket_class` argument is a string, and will always
be one of "SL", "3A", "2A", "1A", "FC", "CC". In the web
UI, this will be shown in parentheses with the full name
of the ticket class.
File: `rajdhani/db.py` <br>
Function: `search_trains`
checks:
- check_flag:
flag: flag_ticketclass_in_search
- check_search_trains:
from_station: BCT
to_station: ADI
expected_trains:
- "12009"
- "12267"
- "12901"
- "12933"
- "19011"
- "59439"
- "59441"
- "09001"
- check_search_trains:
from_station: BCT
to_station: ADI
ticket_class: SL
expected_trains:
- "12901"
- "59439"
- "59441"
- "09001"
- check_search_trains:
from_station: BCT
to_station: ADI
ticket_class: CC
expected_trains:
- "12009"
- "12933"
- "19011"
- check_search_trains:
from_station: BCT
to_station: ADI
ticket_class: 1A
expected_trains:
- "12009"
- "12267"
- "12901"
---
name: search-filters
title: Implement search filters
description: |
Enable the filters on arrival time and departure time by setting
the flag `flag_search_filters` to `True` in the `config.py`.
Consider the arrival time and departure time filters when searching
for trains.
There are 5 time slots available and each one is represented with
a string id.
* Early Morning - midnight to 8:00 am (id=slot1)
* Morning - 8:00 am to noon (id=slot2)
* Afternoon - noon to 4:00pm (id=slot3)
* Evening - 4:00 pm to 8:00pm (id=slot4)
* Night - 8:00 pm to midnight (id=slot5)
The `search_trains` will get a list of slots for `departure_time`
and `arrival_time`. If any slots are provided, then only trains
matching those constraints should be considered. When no slots are
provided, all trains should be included.
File: `rajdhani/db.py` <br>
Function: `search_trains`
checks:
- check_flag:
flag: flag_search_filters
- check_search_trains:
from_station: BCT
to_station: ADI
departure_time: "slot1"
expected_trains:
- "12009"
- "19011"
- check_search_trains:
from_station: BCT
to_station: ADI
departure_time: "slot5"
expected_trains:
- "12267"
- "12901"
- "59441"
- "09001"
- check_search_trains:
from_station: BCT
to_station: ADI
departure_time: ["slot1", "slot5"]
expected_trains:
- "12009"
- "19011"
- "12267"
- "12901"
- "59441"
- "09001"
- check_search_trains:
from_station: BCT
to_station: ADI
arrival_time: "slot1"
expected_trains:
- "12267"
- "12901"
- "59439"
- "09001"
- check_search_trains:
from_station: BCT
to_station: ADI
ticket_class: 1A
arrival_time: "slot1"
expected_trains:
- "12267"
- "12901"
---
name: autocomplete
title: Implement the autocomplete on the home page.
description: |
The autocomplete on the home page to select the from and to stations is
a dummy implementation. Replace that with a correct implementation.
You need to implement the `search_stations` function in `db.py`. It
would get the text entered by user in the `from` or `to` autocomplete
elements on the home page and you need to find all the stations that
contain the entered text either in the station name or station code.
Please remember that you need to this in a case insenstive way.
File: `rajdhani/db.py` <br>
Function: `search_stations`
checks:
- check_autocomplete:
q: sbc
expected_stations:
- SBC
- check_autocomplete:
q: bangal
expected_stations:
- SBC
- BNCE
- BNC
- BJY
- check_autocomplete:
q: guntur
expected_stations:
- GNT
- NGNT
- check_autocomplete:
q: cst
expected_stations:
- CSTM
- check_autocomplete:
q: chennai
expected_stations:
- MS
- MSC
- MAS
- MPKT
- MPK
- MSF
- MSB
---
name: train-schedule
title: Show schedule of a train
description: |
Enable link to show the schedule of each train in the search results
by setting the flag `flag_show_schedule_link` in the config to `True`.
Implement the `get_schedule` function that takes the
train number as argument and returns the schedule.
File: `rajdhani/db.py` <br>
Function: `get_schedule`
checks:
- check_flag:
flag: flag_show_schedule_link
- check_schedule:
train: 12028
ensure_rows:
- [SBC, BANGALORE CITY JN, "1", "-", "06:00"]
- [BNC, BANGALORE CANT, "1", "06:08", "06:10"]
- [BNCE, BANGALORE EAST, "1", "06:12", "06:12"]
- [BYPL, BAIYYAPPANAHALI, "1", "06:15", "06:15"]
- [BBQ, BASIN BRIDGE JN, "1", "10:59", "10:59"]
- [MAS, CHENNAI CENTRAL, "1", "11:00", "-"]
- check_schedule:
train: 12628
ensure_rows:
- [NDLS, NEW DELHI, "1", "-", "21:15"]
- [CSB, SHIVAJI BRIDGE, "1", "21:16", "21:16"]
- [MTJ, MATHURA JN, "1", "23:08", "23:10"]
- [BPL, BHOPAL JN, "2", "06:55", "07:00"]
- [SBC, BANGALORE CITY JN, "3", "13:40", "-"]
# ---
# name: seat-availability
# title: Show availability of seats for each train
# description: |
# Enable showing the number of seats available in each ticket class
# for each train in the search results by setting the flag
# `flag_seat_availability` in the config to `True`.
# Implement the function `get_seat_availability` that takes the
# train number as argument and returns the seat avaiblity for
# each ticket class.
# File: `rajdhani/db.py` <br>
# Function: `get_seat_availability`
# checks:
# - check_flag:
# flag: flag_seat_availability
# - check_not_implemented
---
name: book-ticket
title: Implement booking a ticket.
description: |
Enable ticket booking by setting the flag
`flag_bookings` in the config to `True`.
Implement the function `book_ticket` that takes train
and passenger details and books a ticket by adding an entry
in the database table.
File: `rajdhani/db.py` <br>
Function: `book_ticket`
checks:
- check_flag:
flag: flag_bookings
- check_booking:
train_number: "12628"
from_station_code: NDLS
to_station_code: SBC
passenger_name: Evalu Ator
passenger_email: [email protected]
ticket_class: 3A
date: "2022-12-01"
---
name: login-and-trips
title: Enable login and show trips for the user
description: |
Enable login by enabling the flag `flag_login` and
implement `get_trips` function.
File: `rajdhani/db.py` <br>
Function: `get_trips`
checks:
- check_flag:
flag: flag_login
- check_get_trips:
bookings:
- {"train": "12028", "class": "CC", "date": "2022-09-25"}
- {"train": "04728", "class": "3A", "date": "2022-09-28"}