Skip to content

Commit

Permalink
add test_groups.py
Browse files Browse the repository at this point in the history
Signed-off-by: flashdagger <flashdagger@googlemail.com>
  • Loading branch information
flashdagger committed Oct 27, 2023
1 parent 9da13ab commit 7a87cec
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
------------------
Expand Down
16 changes: 16 additions & 0 deletions tests/test_groups.py
Original file line number Diff line number Diff line change
@@ -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)]
4 changes: 4 additions & 0 deletions tests/test_groups/test_create_group.log
Original file line number Diff line number Diff line change
@@ -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}
{}
4 changes: 2 additions & 2 deletions zammadoo/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 7a87cec

Please sign in to comment.