Skip to content

Commit 230bc55

Browse files
Test session recording blank/control key rendering
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent d7b6825 commit 230bc55

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

tests/test_session_recording_utils.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,54 @@ def __getitem__(self, key: str) -> object:
297297
assert exc_info.value.original_error is not None
298298

299299

300+
def test_parse_session_recordings_response_data_uses_blank_fallback_for_blank_value_keys():
301+
class _BrokenValueLookupMapping(Mapping[str, object]):
302+
def __iter__(self) -> Iterator[str]:
303+
yield " "
304+
305+
def __len__(self) -> int:
306+
return 1
307+
308+
def __getitem__(self, key: str) -> object:
309+
_ = key
310+
raise RuntimeError("cannot read recording value")
311+
312+
with pytest.raises(
313+
HyperbrowserError,
314+
match=(
315+
"Failed to read session recording object value "
316+
"for key '<blank key>' at index 0"
317+
),
318+
) as exc_info:
319+
parse_session_recordings_response_data([_BrokenValueLookupMapping()])
320+
321+
assert exc_info.value.original_error is not None
322+
323+
324+
def test_parse_session_recordings_response_data_preserves_control_placeholders_for_value_keys():
325+
class _BrokenValueLookupMapping(Mapping[str, object]):
326+
def __iter__(self) -> Iterator[str]:
327+
yield "\n\t"
328+
329+
def __len__(self) -> int:
330+
return 1
331+
332+
def __getitem__(self, key: str) -> object:
333+
_ = key
334+
raise RuntimeError("cannot read recording value")
335+
336+
with pytest.raises(
337+
HyperbrowserError,
338+
match=(
339+
"Failed to read session recording object value "
340+
"for key '\\?\\?' at index 0"
341+
),
342+
) as exc_info:
343+
parse_session_recordings_response_data([_BrokenValueLookupMapping()])
344+
345+
assert exc_info.value.original_error is not None
346+
347+
300348
def test_parse_session_recordings_response_data_rejects_string_subclass_recording_keys_before_value_reads():
301349
class _BrokenKey(str):
302350
def __iter__(self):

0 commit comments

Comments
 (0)