-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
17d62b1
commit b696327
Showing
5 changed files
with
32 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,7 +75,8 @@ def login(self, email): | |
|
||
def sync(self): | ||
try: | ||
hamr.sync_app(self.name) | ||
#hamr.sync_app(self.name) | ||
pass | ||
except HamrError as e: | ||
return HamrResponse(ok=False, message=str(e)) | ||
|
||
|
@@ -167,6 +168,8 @@ def validate(self, site): | |
except CheckFailed as e: | ||
return status.fail(str(e)) | ||
except Exception as e: | ||
import traceback | ||
traceback.print_exc() | ||
return status.error(str(e)) | ||
|
||
def do_validate(self, site): | ||
|
@@ -327,12 +330,26 @@ def do_validate(self, site): | |
response = site.post("/book-ticket", data=data) | ||
response.raise_for_status() | ||
|
||
|
||
q = """SELECT * FROM booking ORDER BY id DESC LIMIT 1""" | ||
result = site.query(q) | ||
if not result: | ||
raise CheckFailed("Could not find any bookings") | ||
|
||
row = result[0] | ||
|
||
|
||
for k in "train_number ticket_class date passenger_name passenger_email".split(): | ||
if k not in row: | ||
raise CheckFailed(f"Missing {k!r} column in table booking") | ||
|
||
q = """ | ||
SELECT | ||
train_number, ticket_class, date, | ||
from_station_code, to_station_code, | ||
passenger_name, passenger_email | ||
FROM booking | ||
b.train_number, b.ticket_class, b.date, | ||
b.passenger_name, b.passenger_email, | ||
t.from_station_code, t.to_station_code | ||
FROM booking b | ||
JOIN train t ON b.train_number=t.number | ||
ORDER BY id DESC | ||
LIMIT 1 | ||
""" | ||
|
@@ -389,7 +406,7 @@ def __init__(self, bookings): | |
self.passenger_email = "[email protected]" | ||
|
||
def get_bookings_from_html(self, html): | ||
soup = BeautifulSoup(html) | ||
soup = BeautifulSoup(html, "lxml") | ||
booking_cards = soup.find_all("div", class_="card") | ||
for card in booking_cards: | ||
card_header = card.find("div", class_="card-header").get_text() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -282,9 +282,6 @@ description: | | |
and passenger details and books a ticket by adding an entry | ||
in the database table. | ||
After booking a ticket, the number of available seats for that | ||
train in the booked ticket class should be reduced by one. | ||
File: `rajdhani/db.py` <br> | ||
Function: `book_ticket` | ||
checks: | ||
|
@@ -300,35 +297,6 @@ checks: | |
date: "2022-12-01" | ||
|
||
|
||
--- | ||
name: email-conformation | ||
title: Send an email to confirm the successful booking | ||
description: | | ||
Send an email to the passenger confirming the reservation. | ||
You can use the SMTP credentials from `config.py` to do that. | ||
The booking argument is a dict with keys: `id`, `passenger_name`, | ||
`passenger_email`, `train_number`, `train_name`, `ticket_class`, and `date`. | ||
Note: For testing locally, you can install the | ||
[aiosmtpd](https://aiosmtpd.readthedocs.io/en/latest/) package with pip | ||
and start an SMTP server on port 8025 with `python3 -m aiosmtpd -n`. | ||
File: `rajdhani/notifications.py` <br> | ||
Function: `send_booking_confirmation` | ||
checks: | ||
- check_ticket_confirmation_email: | ||
train: "12028" | ||
ticket_class: "CC" | ||
date: "2022-09-30" | ||
passenger_name: "Eva Lu Ator" | ||
passenger_email: "[email protected]" | ||
- check_ticket_confirmation_email: | ||
train: "16227" | ||
ticket_class: "FC" | ||
date: "2022-09-28" | ||
passenger_name: "Lem E Tweakit" | ||
passenger_email: "[email protected]" | ||
--- | ||
name: login-and-trips | ||
title: Enable login and show trips for the user | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters