mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2025-06-16 05:06:13 +00:00
Clean json returned from server for keys with None values
Add testing
This commit is contained in:
parent
8a3ca73d52
commit
ed96dc8ad5
7 changed files with 188 additions and 4 deletions
51
tests/test_clean_none_dict_values.py
Normal file
51
tests/test_clean_none_dict_values.py
Normal file
|
@ -0,0 +1,51 @@
|
|||
import sys
|
||||
|
||||
import pytest
|
||||
|
||||
sys.path.insert(0, 'jellyfin_kodi')
|
||||
|
||||
from jellyfin.utils import clean_none_dict_values # noqa: E402
|
||||
|
||||
|
||||
@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}),
|
||||
({
|
||||
'dict': {
|
||||
'empty': None,
|
||||
'string': "Hello, Woorld!",
|
||||
},
|
||||
'number': 123,
|
||||
'list': [
|
||||
None,
|
||||
123,
|
||||
"foo",
|
||||
{
|
||||
'empty': None,
|
||||
'number': 123,
|
||||
'string': "foo",
|
||||
'list': [],
|
||||
'dict': {},
|
||||
}
|
||||
]
|
||||
}, {
|
||||
'dict': {
|
||||
'string': "Hello, Woorld!",
|
||||
},
|
||||
'number': 123,
|
||||
'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
|
Loading…
Add table
Add a link
Reference in a new issue