@@ -75,7 +75,8 @@ def login(self, email):
75
75
76
76
def sync (self ):
77
77
try :
78
- hamr .sync_app (self .name )
78
+ #hamr.sync_app(self.name)
79
+ pass
79
80
except HamrError as e :
80
81
return HamrResponse (ok = False , message = str (e ))
81
82
@@ -167,6 +168,8 @@ def validate(self, site):
167
168
except CheckFailed as e :
168
169
return status .fail (str (e ))
169
170
except Exception as e :
171
+ import traceback
172
+ traceback .print_exc ()
170
173
return status .error (str (e ))
171
174
172
175
def do_validate (self , site ):
@@ -327,12 +330,26 @@ def do_validate(self, site):
327
330
response = site .post ("/book-ticket" , data = data )
328
331
response .raise_for_status ()
329
332
333
+
334
+ q = """SELECT * FROM booking ORDER BY id DESC LIMIT 1"""
335
+ result = site .query (q )
336
+ if not result :
337
+ raise CheckFailed ("Could not find any bookings" )
338
+
339
+ row = result [0 ]
340
+
341
+
342
+ for k in "train_number ticket_class date passenger_name passenger_email" .split ():
343
+ if k not in row :
344
+ raise CheckFailed (f"Missing { k !r} column in table booking" )
345
+
330
346
q = """
331
347
SELECT
332
- train_number, ticket_class, date,
333
- from_station_code, to_station_code,
334
- passenger_name, passenger_email
335
- FROM booking
348
+ b.train_number, b.ticket_class, b.date,
349
+ b.passenger_name, b.passenger_email,
350
+ t.from_station_code, t.to_station_code
351
+ FROM booking b
352
+ JOIN train t ON b.train_number=t.number
336
353
ORDER BY id DESC
337
354
LIMIT 1
338
355
"""
@@ -389,7 +406,7 @@ def __init__(self, bookings):
389
406
self .
passenger_email = "[email protected] "
390
407
391
408
def get_bookings_from_html (self , html ):
392
- soup = BeautifulSoup (html )
409
+ soup = BeautifulSoup (html , "lxml" )
393
410
booking_cards = soup .find_all ("div" , class_ = "card" )
394
411
for card in booking_cards :
395
412
card_header = card .find ("div" , class_ = "card-header" ).get_text ()
0 commit comments