Skip to content

Commit 2dce66b

Browse files
committed
Add test for buildQueryKey
1 parent 1c2fc15 commit 2dce66b

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

tests/test_fetch_items.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,25 @@ def test_find_items_empty_data(plex):
3939
assert len(result) == 0
4040
result = plex.findItems(Element("MediaContainer"))
4141
assert isinstance(result, MediaContainer)
42+
43+
44+
def test_buildQueryKey(plex):
45+
key = '/test/key'
46+
key_with_query = f'{key}?foo=bar'
47+
kwargs = {'index': 1, 'type': 2}
48+
49+
query_key = plex._buildQueryKey(key)
50+
assert query_key.startswith(key)
51+
assert '?includeGuids=1' in query_key
52+
53+
query_key = plex._buildQueryKey(key, **kwargs)
54+
query_params = []
55+
for k, v in kwargs.items():
56+
query_param = f'{k}={v}'
57+
assert query_param in query_key
58+
query_params.append(query_param)
59+
60+
query_key = plex._buildQueryKey(key_with_query, **kwargs)
61+
assert query_key.startswith(key_with_query)
62+
assert '&includeGuids=1' in query_key
63+
assert f'&{"&".join(query_params)}' in query_key

0 commit comments

Comments
 (0)