|
7 | 7 | import pytest |
8 | 8 |
|
9 | 9 | from getstream.models import GetCallResponse, OwnCapability, OwnCapabilityType |
| 10 | +from getstream.base import _strip_none |
10 | 11 | from getstream.utils import ( |
11 | 12 | datetime_from_unix_ns, |
12 | 13 | encode_datetime, |
@@ -337,6 +338,31 @@ def test_call_session_response_from_dict_with_none(): |
337 | 338 | assert call_session.ended_at is None |
338 | 339 |
|
339 | 340 |
|
| 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 | + |
340 | 366 | @pytest.mark.skip("fixture is not longer valid, skip for now") |
341 | 367 | def test_get_call_response_from_dict(): |
342 | 368 | # Read the fixture file |
|
0 commit comments