Skip to content

Commit

Permalink
fix get_groups_members params #112
Browse files Browse the repository at this point in the history
  • Loading branch information
bensteUEM committed Oct 4, 2024
1 parent 315539c commit ae5e2f5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
9 changes: 6 additions & 3 deletions churchtools_api/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,15 +334,15 @@ def get_groups_members(
"""
url = self.domain + "/api/groups/members"
headers = {"accept": "application/json"}
params = {}
params = {"ids[]": group_ids, with_deleted: with_deleted}

response = self.session.get(url=url, headers=headers, params=params)

if response.status_code == 200:
response_content = json.loads(response.content)

response_data = self.combine_paginated_response_data(
response_content, url=url, headers=headers
response_content, url=url, headers=headers, params=params
)
result_list = (
[response_data] if isinstance(response_data, dict) else response_data
Expand All @@ -363,7 +363,10 @@ def get_groups_members(
return result_list
else:
logger.warning(
"%s Something went wrong fetching group members: %s", response.status_code, response.content)
"%s Something went wrong fetching group members: %s",
response.status_code,
response.content,
)

def add_group_member(self, group_id: int, person_id: int, **kwargs) -> dict:
"""Add a member to a group.
Expand Down
12 changes: 12 additions & 0 deletions tests/test_churchtools_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,18 @@ def test_get_groups_members(self) -> None:
compare_result = [group["groupId"] for group in group_result]
self.assertIn(EXPECTED_GROUP_ID, compare_result)

# 3. problematic result group_ids, grouptype_role_ids and person_id
SAMPLE_GROUP_IDS = [99, 68, 93]
SAMPLE_GROUPTYPE_ROLE_IDS = [9, 16]
SAMPLE_PERSON_IDS = [54]

result = self.api.get_groups_members(
group_ids=SAMPLE_GROUP_IDS,
grouptype_role_ids=SAMPLE_GROUPTYPE_ROLE_IDS,
person_ids=SAMPLE_PERSON_IDS,
)
assert len(result) == 1

def test_add_and_remove_group_members(self)->None:
"""IMPORTANT - This test method and the parameters used depend on the target system!
the hard coded sample exists on ELKW1610.KRZ.TOOLS.
Expand Down

0 comments on commit ae5e2f5

Please sign in to comment.