Skip to content
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
21 changes: 8 additions & 13 deletions churchtools_api/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,19 +566,14 @@ def _add_service_group_notes(
service_groups: the service groups that are known
"""
for item in service_group_notes:
if len(item["serviceGroupNotes"]) > 0:
for note in item["serviceGroupNotes"]:
if (
note["serviceGroupId"] in service_groups
and len(note["note"]) > 0
):
document.add_heading(
"Bemerkung für {}:".format(
service_groups[note["serviceGroupId"]]["name"],
),
level=4,
)
document.add_paragraph(note["note"])
if item["serviceGroupId"] in service_groups and len(item["note"]) > 0:
document.add_heading(
"Bemerkung für {}:".format(
service_groups[item["serviceGroupId"]]["name"],
),
level=4,
)
document.add_paragraph(item["note"])

def get_persons_with_service(self, eventId: int, serviceId: int) -> list[dict]:
"""Helper function which should return the list of persons.
Expand Down
28 changes: 28 additions & 0 deletions tests/test_churchtools_api_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,3 +388,31 @@ def test_get_persons_with_service(self) -> None:

assert len(result) >= 1
assert result[0]["serviceId"] >= 1

def test_get_event_agenda_docx(self) -> None:
"""Checks downloadability of a sample event as docx.

Does NOT compare it's content!

IMPORTANT - This test method and the parameters used depend on target system!
the hard coded sample exists on ELKW1610.KRZ.TOOLS.
"""
SAMPLE_EVENT_ID = 4102
SAMPLE_SELECTED_SERVICES = [1, 3, 4, 7, 5, 6]

agenda = self.api.get_event_agenda(eventId=SAMPLE_EVENT_ID)
service_groups = self.api.get_event_masterdata(
resultClass="serviceGroups", returnAsDict=True
)
selectedServiceGroups = {
key: value
for key, value in service_groups.items()
if key in SAMPLE_SELECTED_SERVICES
}
document = self.api.get_event_agenda_docx(
agenda,
serviceGroups=selectedServiceGroups,
excludeBeforeEvent=False,
)

assert document
Loading