Skip to content

Commit d367cf2

Browse files
ai: apply changes for #935 (1 review thread)
Addresses: - #3875712372 at tests/unit/test_kernel_client.py:310 Signed-off-by: peco-engineer-bot[bot] <peco-engineer-bot[bot]@users.noreply.github.com>
1 parent 2bfadd4 commit d367cf2

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

tests/unit/test_kernel_client.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,57 @@ def test_open_session_rejects_timestamp_as_string_true(monkeypatch):
325325
session_ctor.assert_not_called()
326326

327327

328+
@pytest.mark.parametrize(
329+
"value",
330+
["TRUE", "True", "true"], # ``.lower()`` normalizes case before comparison
331+
)
332+
def test_open_session_rejects_timestamp_as_string_true_case_insensitive(
333+
monkeypatch, value
334+
):
335+
"""A truthy ``TIMESTAMP_AS_STRING_CONFIG`` string is rejected
336+
regardless of case — the guard lower-cases before comparing."""
337+
session_ctor = MagicMock()
338+
monkeypatch.setattr(kernel_client._kernel, "Session", session_ctor)
339+
340+
c = _make_client()
341+
342+
with pytest.raises(Error, match="timestampAsString cannot be changed"):
343+
c.open_session(
344+
session_configuration={
345+
"spark.thriftserver.arrowBasedRowSet.timestampAsString": value
346+
},
347+
catalog=None,
348+
schema=None,
349+
)
350+
351+
session_ctor.assert_not_called()
352+
353+
354+
@pytest.mark.parametrize(
355+
"value",
356+
["false", "False", "FALSE"], # a valid pin must NOT be rejected, any case
357+
)
358+
def test_open_session_accepts_timestamp_as_string_false(monkeypatch, value):
359+
"""A legitimate ``TIMESTAMP_AS_STRING_CONFIG = "false"`` pin (any
360+
case) still opens the session — the guard rejects only non-false
361+
overrides, so a valid config is not wrongly refused."""
362+
fake_session = MagicMock()
363+
fake_session.return_value.session_id = "sess-id"
364+
monkeypatch.setattr(kernel_client._kernel, "Session", fake_session)
365+
366+
c = _make_client()
367+
368+
c.open_session(
369+
session_configuration={
370+
"spark.thriftserver.arrowBasedRowSet.timestampAsString": value
371+
},
372+
catalog=None,
373+
schema=None,
374+
)
375+
376+
fake_session.assert_called_once()
377+
378+
328379
@pytest.mark.parametrize(
329380
"kwargs, expected_flag",
330381
[

0 commit comments

Comments
 (0)