From b235e491855ed9efd8a4cb5ba69726524e825deb Mon Sep 17 00:00:00 2001 From: Etienne Callies Date: Thu, 3 Oct 2024 23:13:59 +0200 Subject: [PATCH] make sure tests are on two year --- home/utils/date_utils.py | 8 ++++++-- scraping/tests/tests_llm_parsing.py | 8 +++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/home/utils/date_utils.py b/home/utils/date_utils.py index 61fcf52..955aee4 100644 --- a/home/utils/date_utils.py +++ b/home/utils/date_utils.py @@ -11,8 +11,12 @@ def ts_us_to_datetime(timestamp_us): return make_aware(datetime.fromtimestamp(timestamp_us / 1000000.0)) -def get_year_start_and_end(year: int): - return datetime(year, 1, 1), datetime(year, 12, 31, 23, 59, 59) +def get_year_start(year: int): + return datetime(year, 1, 1) + + +def get_year_end(year: int): + return datetime(year, 12, 31, 23, 59, 59) def get_current_year() -> int: diff --git a/scraping/tests/tests_llm_parsing.py b/scraping/tests/tests_llm_parsing.py index 0e0c8c4..7caf24b 100644 --- a/scraping/tests/tests_llm_parsing.py +++ b/scraping/tests/tests_llm_parsing.py @@ -6,7 +6,7 @@ import simple_cache from dotenv import load_dotenv -from home.utils.date_utils import get_year_start_and_end +from home.utils.date_utils import get_year_start, get_year_end from scraping.parse.llm_client import OpenAILLMClient, get_openai_client from scraping.parse.parse_with_llm import parse_with_llm, get_llm_model, get_prompt_template from scraping.parse.schedules import SchedulesList, get_merged_schedules_list @@ -77,7 +77,8 @@ def test_llm_parsing(self): self.assertIsNotNone(schedules_list) # print(schedules_list.model_dump_json()) - year_start, year_end = get_year_start_and_end(year) + year_start = get_year_start(year) + year_end = get_year_end(year + 1) are_equivalent, reason = are_schedules_list_equivalent( schedules_list, expected_schedules_list, year_start, year_end) @@ -126,7 +127,8 @@ def test_llm_parsing_with_cancellation(self): self.assertIsNotNone(schedules_list2) # print(schedules_list2.model_dump_json()) - year_start, year_end = get_year_start_and_end(year) + year_start = get_year_start(year) + year_end = get_year_end(year + 1) merged_schedules_list = get_merged_schedules_list([ schedules_list1,