Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests #88

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions tests/test_missing_date_checker/test_scrape_missing_dates.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import datetime
import pytz

import pytest
from sqlalchemy import func, create_engine
Expand All @@ -20,20 +21,17 @@ async def test_scrape_missing_dates(tmp_path) -> None:
booking_details_param = BookingDetails(city='Osaka', group_adults=1, num_rooms=1, group_children=0,
selected_currency='USD', scrape_only_hotel=True)

today = datetime.datetime.today()
if today.month == 12:
month = 1
year = today.year + 1
else:
month = today.month + 1
year = today.year
today = datetime.datetime.now(pytz.UTC)
next_month = (today.replace(day=1) + datetime.timedelta(days=32)).replace(day=1)
year, month = next_month.year, next_month.month

month_str = str(month).zfill(2)

first_missing_date = f'{year}-{month_str}-01'
second_missing_date = f'{year}-{month_str}-11'
third_missing_date = f'{year}-{month_str}-20'
missing_dates = [first_missing_date, second_missing_date, third_missing_date]
missing_dates = [
f'{year}-{month_str}-01',
f'{year}-{month_str}-11',
f'{year}-{month_str}-20'
]

await scrape_missing_dates(missing_dates_list=missing_dates, booking_details_class=booking_details_param,
engine=engine)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import datetime
import pytz

import pytest

Expand All @@ -7,7 +8,7 @@

@pytest.mark.asyncio
async def test_whole_month_graphql_scraper():
today = datetime.datetime.now()
today = datetime.datetime.now(pytz.UTC)
current_mth = today.month
current_year = today.year

Expand All @@ -24,7 +25,7 @@ async def test_whole_month_graphql_scraper():

@pytest.mark.asyncio
async def test_whole_month_graphql_scraper_past_date():
today = datetime.datetime.now()
today = datetime.datetime.now(pytz.UTC)
past_mth = today.month - 1
current_year = today.year

Expand All @@ -34,4 +35,4 @@ async def test_whole_month_graphql_scraper_past_date():
country='Japan')
df = await scraper.scrape_whole_month()

assert df.empty
assert df.empty
Loading