Skip to content

Commit

Permalink
adding samedaty get_events workaround and warn logs #109
Browse files Browse the repository at this point in the history
  • Loading branch information
bensteUEM committed Oct 8, 2024
1 parent b78c352 commit ff2479c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
7 changes: 7 additions & 0 deletions churchtools_api/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
21 changes: 21 additions & 0 deletions tests/test_churchtools_api_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down

0 comments on commit ff2479c

Please sign in to comment.