Skip to content

Commit cc6f9b0

Browse files
committed
fix(event_agenda): get_event_agenda_docx
(#274)
1 parent 1bc0ec0 commit cc6f9b0

2 files changed

Lines changed: 36 additions & 13 deletions

File tree

churchtools_api/events.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -566,19 +566,14 @@ def _add_service_group_notes(
566566
service_groups: the service groups that are known
567567
"""
568568
for item in service_group_notes:
569-
if len(item["serviceGroupNotes"]) > 0:
570-
for note in item["serviceGroupNotes"]:
571-
if (
572-
note["serviceGroupId"] in service_groups
573-
and len(note["note"]) > 0
574-
):
575-
document.add_heading(
576-
"Bemerkung für {}:".format(
577-
service_groups[note["serviceGroupId"]]["name"],
578-
),
579-
level=4,
580-
)
581-
document.add_paragraph(note["note"])
569+
if item["serviceGroupId"] in service_groups and len(item["note"]) > 0:
570+
document.add_heading(
571+
"Bemerkung für {}:".format(
572+
service_groups[item["serviceGroupId"]]["name"],
573+
),
574+
level=4,
575+
)
576+
document.add_paragraph(item["note"])
582577

583578
def get_persons_with_service(self, eventId: int, serviceId: int) -> list[dict]:
584579
"""Helper function which should return the list of persons.

tests/test_churchtools_api_events.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,3 +388,31 @@ def test_get_persons_with_service(self) -> None:
388388

389389
assert len(result) >= 1
390390
assert result[0]["serviceId"] >= 1
391+
392+
def test_get_event_agenda_docx(self) -> None:
393+
"""Checks downloadability of a sample event as docx.
394+
395+
Does NOT compare it's content!
396+
397+
IMPORTANT - This test method and the parameters used depend on target system!
398+
the hard coded sample exists on ELKW1610.KRZ.TOOLS.
399+
"""
400+
SAMPLE_EVENT_ID = 4102
401+
SAMPLE_SELECTED_SERVICES = [1, 3, 4, 7, 5, 6]
402+
403+
agenda = self.api.get_event_agenda(eventId=SAMPLE_EVENT_ID)
404+
service_groups = self.api.get_event_masterdata(
405+
resultClass="serviceGroups", returnAsDict=True
406+
)
407+
selectedServiceGroups = {
408+
key: value
409+
for key, value in service_groups.items()
410+
if key in SAMPLE_SELECTED_SERVICES
411+
}
412+
document = self.api.get_event_agenda_docx(
413+
agenda,
414+
serviceGroups=selectedServiceGroups,
415+
excludeBeforeEvent=False,
416+
)
417+
418+
assert document

0 commit comments

Comments
 (0)