-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eda56a7
commit 8252cfc
Showing
6 changed files
with
97 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: UTF-8 -*- | ||
from contextlib import suppress | ||
|
||
import pytest | ||
|
||
from zammadoo.utils import TypedTag | ||
|
||
|
||
def test_representation_of_tags(request, client): | ||
client_url = request.config.getoption("--client-url") | ||
assert repr(client.tags) == f"<Tags '{client_url}/tag_list'>" | ||
|
||
|
||
def test_tag_iteration(rclient): | ||
for tag in rclient.tags: | ||
assert tag.keys() == TypedTag.__required_keys__ | ||
break | ||
|
||
|
||
def test_mutable_tag_operations(rclient): | ||
tag_name = "__pytest__" | ||
new_tag_name = "__pytest_new__" | ||
tags = rclient.tags | ||
|
||
# make sure tag does not exist | ||
with suppress(KeyError): | ||
tags.delete(tag_name) | ||
with suppress(KeyError): | ||
tags.delete(new_tag_name) | ||
|
||
assert tag_name not in tags | ||
|
||
with pytest.raises(KeyError, match=tag_name): | ||
tags.delete(tag_name) | ||
|
||
tags.create(tag_name) | ||
assert tag_name in tags | ||
tag_info = tags[tag_name] | ||
assert tag_info["name"] == tag_name | ||
assert tag_info["count"] == 0 | ||
|
||
assert tag_name in tags.search(tag_name) | ||
|
||
tags.cache.clear() | ||
tags.rename(tag_name, new_tag_name) | ||
assert new_tag_name in tags | ||
assert tag_name not in tags | ||
|
||
tags.cache.clear() | ||
assert tag_info["id"] == tags[new_tag_name]["id"] | ||
|
||
tags.delete(new_tag_name) |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters