Skip to content

Commit 97bf1e6

Browse files
committed
test: add unit tests for the stripping behavior
1 parent 1f106ba commit 97bf1e6

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/test_decoding.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import pytest
88

99
from getstream.models import GetCallResponse, OwnCapability, OwnCapabilityType
10+
from getstream.base import _strip_none
1011
from getstream.utils import (
1112
datetime_from_unix_ns,
1213
encode_datetime,
@@ -337,6 +338,31 @@ def test_call_session_response_from_dict_with_none():
337338
assert call_session.ended_at is None
338339

339340

341+
def test_strip_none_flat_dict():
342+
assert _strip_none({"a": 1, "b": None, "c": "x"}) == {"a": 1, "c": "x"}
343+
344+
345+
def test_strip_none_nested_dict():
346+
payload = {"a": 1, "b": None, "nested": {"c": None, "d": 2}}
347+
assert _strip_none(payload) == {"a": 1, "nested": {"d": 2}}
348+
349+
350+
def test_strip_none_preserves_empty_collections():
351+
payload = {"tags": [], "meta": {}, "name": None}
352+
assert _strip_none(payload) == {"tags": [], "meta": {}}
353+
354+
355+
def test_strip_none_preserves_list_elements():
356+
payload = {"ids": [1, None, 3], "data": [{"a": None, "b": 2}]}
357+
assert _strip_none(payload) == {"ids": [1, None, 3], "data": [{"b": 2}]}
358+
359+
360+
def test_strip_none_passthrough_scalars():
361+
assert _strip_none(42) == 42
362+
assert _strip_none("hello") == "hello"
363+
assert _strip_none(True) is True
364+
365+
340366
@pytest.mark.skip("fixture is not longer valid, skip for now")
341367
def test_get_call_response_from_dict():
342368
# Read the fixture file

0 commit comments

Comments
 (0)