diff --git a/HISTORY.rst b/HISTORY.rst index 6d92b0d..556146d 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -27,7 +27,7 @@ History * resource items are now cached when using iteration * fromisoformat conversion in Python <3.10 supporting Zulu offset format - * :class:`roles.Roles` wrongly supported `search` + * :class:`roles.Roles` and :class:`roles.Groups` wrongly supported `search` 0.1.0 (2023-10-08) ------------------ diff --git a/tests/test_groups.py b/tests/test_groups.py new file mode 100644 index 0000000..5b949d4 --- /dev/null +++ b/tests/test_groups.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python +# -*- coding: UTF-8 -*- + + +def test_create_group(rclient, temporary_resources): + with temporary_resources("groups") as groups: + new_group = rclient.groups.create("pytest_group") + groups.append(new_group.view()) + assert new_group.active is True + assert new_group.note is None + + +def test_group_users_attribute(client): + group = client.groups(1, info={"id": 1, "user_ids": [1, 2, 3]}) + users = client.users + assert group.users == [users(1), users(2), users(3)] diff --git a/tests/test_groups/test_create_group.log b/tests/test_groups/test_create_group.log new file mode 100644 index 0000000..347027c --- /dev/null +++ b/tests/test_groups/test_create_group.log @@ -0,0 +1,4 @@ +{"method": "POST", "url": "https://localhost/api/v1/groups", "status_code": 201, "reason": "Created", "headers": {"Content-Type": "application/json; charset=utf-8", "Content-Length": "359"}, "encoding": "utf-8", "content_size": 359} +{"id":5,"signature_id":null,"email_address_id":null,"name":"pytest_group","assignment_timeout":null,"follow_up_possible":"yes","reopen_time_in_days":null,"follow_up_assignment":true,"active":true,"shared_drafts":true,"note":null,"updated_by_id":3,"created_by_id":3,"created_at":"2023-10-27T04:24:41.236Z","updated_at":"2023-10-27T04:24:41.236Z","user_ids":[]} +{"method": "DELETE", "url": "https://localhost/api/v1/groups/5#fixture", "status_code": 200, "reason": "OK", "headers": {"Content-Type": "application/json; charset=utf-8", "Content-Length": "2"}, "encoding": "utf-8", "content_size": 2} +{} diff --git a/zammadoo/groups.py b/zammadoo/groups.py index e96d463..33e655d 100644 --- a/zammadoo/groups.py +++ b/zammadoo/groups.py @@ -3,7 +3,7 @@ from typing import TYPE_CHECKING, List from .resource import NamedResource -from .resources import CreatableT, SearchableT +from .resources import CreatableT, IterableT if TYPE_CHECKING: from .client import Client @@ -21,7 +21,7 @@ def users(self) -> List["User"]: return list(map(users, self["user_ids"])) -class Groups(SearchableT[Group], CreatableT[Group]): +class Groups(IterableT[Group], CreatableT[Group]): """Groups(...)""" _RESOURCE_TYPE = Group