diff --git a/churchtools_api/events.py b/churchtools_api/events.py index a612427..4bab312 100644 --- a/churchtools_api/events.py +++ b/churchtools_api/events.py @@ -62,6 +62,13 @@ def get_events(self, **kwargs) -> list[dict]: to_ = to_.strftime("%Y-%m-%d") if len(to_) == 10: params["to"] = to_ + 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 - github #109", + ) + params["to"] = (kwargs["to_"] + timedelta(days=1)).strftime( + "%Y-%m-%d" + ) # TODO #109 CT issue elif "to_" in kwargs: logger.warning("Use of to_ is only allowed together with from_") if "canceled" in kwargs: diff --git a/tests/test_churchtools_api_events.py b/tests/test_churchtools_api_events.py index d3eb9cd..bc327c8 100644 --- a/tests/test_churchtools_api_events.py +++ b/tests/test_churchtools_api_events.py @@ -158,6 +158,27 @@ def test_get_events(self) -> None: # TODO add test cases for uncommon parts #24 * canceled, include + def test_get_events_sameday(self) -> None: + """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) -> None: """IMPORTANT - This test method and the parameters used depend on the target system!