From 3a4bc7658aa31ef64c3fb7909afcf6b4aab46ef6 Mon Sep 17 00:00:00 2001 From: bensteUEM Date: Fri, 4 Oct 2024 19:46:30 +0200 Subject: [PATCH] adding warning for workaround in events api #106 --- churchtools_api/events.py | 3 +++ tests/test_churchtools_api_events.py | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/churchtools_api/events.py b/churchtools_api/events.py index 78d2beb..7af529e 100644 --- a/churchtools_api/events.py +++ b/churchtools_api/events.py @@ -76,6 +76,9 @@ def get_events(self, **kwargs) -> list[dict]: if 'include' in kwargs.keys(): params['include'] = kwargs['include'] + if from_ == to_ : + logger.warning("As of 29. Sept 2024 there is a known bug which will not return results for same day searches! - reported to CT team as issue 130629") + response = self.session.get(url=url, headers=headers, params=params) if response.status_code == 200: diff --git a/tests/test_churchtools_api_events.py b/tests/test_churchtools_api_events.py index a9665a2..1f2a6a3 100644 --- a/tests/test_churchtools_api_events.py +++ b/tests/test_churchtools_api_events.py @@ -132,6 +132,24 @@ def test_get_events(self): # TODO add test cases for uncommon parts #24 * canceled, include + def test_get_events_sameday(self): + """Special test case checking confirmity of event search for same day. + + See https://github.com/bensteUEM/ChurchToolsAPI/issues/109. + + IMPORTANT - This test method and the parameters used depend on the target system! + the hard coded sample exists on ELKW1610.KRZ.TOOLS + """ + SAMPLE_DAY = datetime(year=2024,month=9,day=29) + events = self.api.get_events(from_= SAMPLE_DAY, to_=SAMPLE_DAY) + + logger.warning("As of 29. Sept 2024 there is a known bug which will not return results for same day searches! - reported to CT team as issue 130629") + assert len(events) > 0 + + retrieved_dates = {datetime.strptime(event["startDate"][:10],"%Y-%m-%d") for event in events} + assert {SAMPLE_DAY} == retrieved_dates + + def test_get_AllEventData_ajax(self): """ IMPORTANT - This test method and the parameters used depend on the target system!