Files
hermes-agent/tests/persistence_sqlite/conversation/test_session_identifier_binding.py
yoniebans b651abfa32 test(persistence/sqlite): conversation cases
The SQLite backend's conversation cases.
2026-11-17 17:49:47 +01:00

27 lines
1.1 KiB
Python

"""Session identifiers reach the SQLite store without stringifying unsupported values."""
import sqlite3
import pytest
from persistence import PermanentStoreError
from persistence.conversation.sessions import NewSession, SessionCountQuery
@pytest.mark.parametrize("identifier", [123, True])
def test_numeric_session_create_keeps_the_native_refusal(backend, scope_a, identifier):
with pytest.raises(TypeError, match="can only concatenate str"):
backend.open(scope_a).sessions.create(NewSession(identifier, "cli"))
@pytest.mark.parametrize("identifier", [["bad"], {"bad": 1}])
def test_container_session_ids_keep_the_binding_error(backend, scope_a, identifier):
sessions = backend.open(scope_a).sessions
with pytest.raises(PermanentStoreError) as refusal:
sessions.get(identifier)
assert isinstance(refusal.value.__cause__, sqlite3.ProgrammingError)
with pytest.raises(PermanentStoreError) as refusal:
sessions.create(NewSession(identifier, "cli"))
assert isinstance(refusal.value.__cause__, sqlite3.ProgrammingError)
assert sessions.count_sessions(SessionCountQuery(include_archived=True)) == 0