Skip to content

Commit 44ab34c

Browse files
committed
Fix XlsxReder methods, modify tests
1 parent 73ae321 commit 44ab34c

File tree

5 files changed

+34
-36
lines changed

5 files changed

+34
-36
lines changed

tests/test_search_flight.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,39 +16,39 @@ def test_search_flight_general(self):
1616
search_flight.open_flights_tab()
1717
search_flight.set_trip_type("One Way")
1818
search_flight.set_cabin_class("First") # Cabin class: Economy, First, Business
19-
search_flight.set_loc_from("LUZ")
20-
search_flight.set_loc_to("OSL")
21-
search_flight.set_start_date("2019", "Dec", "14")
19+
search_flight.set_loc_from("LIS")
20+
search_flight.set_loc_to("JFK")
21+
search_flight.set_start_date("2019", "Dec", "31")
2222
search_flight.set_adults_number(2)
2323
search_flight.set_kids_number(4)
2424
search_flight.set_infants_number(1)
2525
search_flight.search_perform()
2626

27-
@allure.title("Search flight test: from Warsaw to Aruba")
28-
@allure.description("This is test of searching flight from Warsaw to Aruba and return")
29-
def test_search_flight_round_trip(self):
27+
@allure.title("Search flight test: one way")
28+
@allure.description("This is test of searching one way flight")
29+
@pytest.mark.parametrize("data", XlsxReader.get_xlsx_flights_data())
30+
def test_search_flight_one_way(self, data):
3031
search_flight = SearchFlightsForm(self.driver)
3132
search_flight.open_page()
3233
search_flight.open_flights_tab()
33-
search_flight.set_round_trip()
34-
search_flight.set_cabin_class("Economy") # Cabin class: Economy, First, Business
35-
search_flight.set_loc_from("WAW")
36-
search_flight.set_loc_to("AUA")
37-
search_flight.set_start_date("2020", "Nov", "27")
38-
search_flight.set_end_date("2020", "Dec", "30")
39-
search_flight.set_adults_number(1)
40-
search_flight.set_kids_number(0)
41-
search_flight.set_infants_number(0)
34+
search_flight.set_one_way()
35+
search_flight.set_cabin_class(data.cabin_class)
36+
search_flight.set_loc_from(data.location_from)
37+
search_flight.set_loc_to(data.location_to)
38+
search_flight.set_start_date(data.start_year, data.start_month, data.start_day)
39+
search_flight.set_adults_number(data.adults_num)
40+
search_flight.set_kids_number(data.kids_num)
41+
search_flight.set_infants_number(data.infants_num)
4242
search_flight.search_perform()
4343

44-
@allure.title("Search flight data-driven tests")
45-
@allure.description("This is data-driven tests of searching flight")
44+
@allure.title("Search flight test: round trip")
45+
@allure.description("This is test of searching round trip flight")
4646
@pytest.mark.parametrize("data", XlsxReader.get_xlsx_flights_data())
47-
def test_search_flight_data_driven(self, data):
47+
def test_search_flight_round_trip(self, data):
4848
search_flight = SearchFlightsForm(self.driver)
4949
search_flight.open_page()
5050
search_flight.open_flights_tab()
51-
search_flight.set_trip_type(data.trip_type)
51+
search_flight.set_round_trip()
5252
search_flight.set_cabin_class(data.cabin_class)
5353
search_flight.set_loc_from(data.location_from)
5454
search_flight.set_loc_to(data.location_to)

tests/test_search_hotel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class TestHotelSearch:
1111

1212
@allure.title("Search hotel test")
1313
@allure.description("This is test of searching hotel in Warsaw")
14-
def test_search_hote_1(self):
14+
def test_search_hotel_1(self):
1515
search_hotel = SearchHotelsForm(self.driver)
1616
search_hotel.open_page()
1717
search_hotel.set_destination("Warsaw")

utils/read_xlsx.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
class XlsxReader:
88
@staticmethod
99
def get_xlsx_hotels_data():
10-
wb = xlrd.open_workbook(f"../utils/search_hotels_input_data.xlsx")
10+
wb = xlrd.open_workbook(f"./utils/search_hotels_input_data.xlsx")
1111
sheet = wb.sheet_by_index(0)
1212
data = []
1313

@@ -22,23 +22,22 @@ def get_xlsx_hotels_data():
2222

2323
@staticmethod
2424
def get_xlsx_flights_data():
25-
wb = xlrd.open_workbook(f"../utils/search_flights_input_data.xlsx")
25+
wb = xlrd.open_workbook(f"./utils/search_flights_input_data.xlsx")
2626
sheet = wb.sheet_by_index(0)
2727
data = []
2828

2929
for i in range(1, sheet.nrows):
3030
search_flights_data = SearchFlightsData(sheet.cell(i, 0).value, # cabin class
31-
sheet.cell(i, 1).value, # trip type
32-
sheet.cell(i, 2).value, # location from
33-
sheet.cell(i, 3).value, # location to
34-
int(sheet.cell(i, 4).value), # start year
35-
sheet.cell(i, 5).value, # start month
36-
int(sheet.cell(i, 6).value), # start day
37-
int(sheet.cell(i, 7).value), # end year
38-
sheet.cell(i, 8).value, # end month
39-
int(sheet.cell(i, 9).value), # end day
40-
int(sheet.cell(i, 10).value), # adults number
41-
int(sheet.cell(i, 11).value), # kids number
42-
int(sheet.cell(i, 12).value)) # infants number
31+
sheet.cell(i, 1).value, # location from
32+
sheet.cell(i, 2).value, # location to
33+
int(sheet.cell(i, 3).value), # start year
34+
sheet.cell(i, 4).value, # start month
35+
int(sheet.cell(i, 5).value), # start day
36+
int(sheet.cell(i, 6).value), # end year
37+
sheet.cell(i, 7).value, # end month
38+
int(sheet.cell(i, 8).value), # end day
39+
int(sheet.cell(i, 9).value), # adults number
40+
int(sheet.cell(i, 10).value), # kids number
41+
int(sheet.cell(i, 11).value)) # infants number
4342
data.append(search_flights_data)
4443
return data

utils/search_flights_data.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
class SearchFlightsData:
22

3-
def __init__(self, cabin_class, trip_type, location_from, location_to, start_year, start_month, start_day,
3+
def __init__(self, cabin_class, location_from, location_to, start_year, start_month, start_day,
44
end_year, end_month, end_day, adults_num, kids_num, infants_num):
55
self.cabin_class = cabin_class
6-
self.trip_type = trip_type
76
self.location_from = location_from
87
self.location_to = location_to
98
self.start_year = start_year

utils/search_flights_input_data.xlsx

-44 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)