jellyfin-kodi/tests/test_clean_none_dict_values.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

54 lines
1.4 KiB
Python
Raw Permalink Normal View History

import pytest
2021-10-10 17:44:32 +00:00
from jellyfin_kodi.jellyfin.utils import clean_none_dict_values
@pytest.mark.parametrize(
"obj,expected",
[
(None, None),
([None, 1, 2, 3, None, 4], [None, 1, 2, 3, None, 4]),
({"foo": None, "bar": 123}, {"bar": 123}),
(
{
2024-06-10 09:19:47 +00:00
"dict": {
"empty": None,
"string": "Hello, Woorld!",
},
"number": 123,
2024-06-10 09:19:47 +00:00
"list": [
None,
123,
"foo",
{
"empty": None,
"number": 123,
"string": "foo",
2024-06-10 09:19:47 +00:00
"list": [],
"dict": {},
},
],
},
{
2024-06-10 09:19:47 +00:00
"dict": {
"string": "Hello, Woorld!",
2024-06-10 09:19:47 +00:00
},
"number": 123,
2024-06-10 09:19:47 +00:00
"list": [
None,
123,
"foo",
{
"number": 123,
"string": "foo",
"list": [],
"dict": {},
},
],
},
),
],
)
def test_clean_none_dict_values(obj, expected):
assert clean_none_dict_values(obj) == expected