Test files received fixtures by importing them from a sibling test module (`from tests.x.test_y import daemon, owner # noqa: F401`). Every test that then takes the fixture as a parameter is a ruff F811 redefinition, which main's code-health ratchet blocks (it ignores noqa), and it couples test modules to each other. Move each shared fixture to where pytest resolves it by name, scopes unchanged (all function-scoped): - model_peer -> tests/_fixtures/model_peer.py, registered in tests/conftest.py (used by gateway, acp_adapter and hermes_cli tests) - daemon, server_spec -> tests/acp_adapter/conftest.py - owner, api -> tests/gateway/conftest.py - worker -> new tests/hermes_state/conftest.py - test_session_hosted_rpc's `owner` (a different object: hosted-room authority on its own loop) -> tests/gateway/conftest.py as `hosted_owner`, so it does not collide with the API `owner`; its three user files rename the parameter. Conftest fixtures import lazily so the gateway conftest still installs its telegram/discord mocks before any gateway module loads. Plain helpers (viewer, editor, control, policy) stay imported from their modules. Also drop an unused HostedRoomAttachmentStore local in test_hosted_attachment_bridge (F841) while that file is touched. Same tests collected and passing in every touched file. (cherry picked from commit 463102382f8cd9bbc9e0c605be7e1345165efda4)
21 lines
1.3 KiB
Python
21 lines
1.3 KiB
Python
"""Compression's pre-publication flush uses the ordinary annotated append helper."""
|
|
|
|
|
|
def test_compression_flush_returns_canonical_annotations_and_keeps_turn_guard(worker):
|
|
db, store = worker
|
|
assert store.try_acquire_session_turn_lease('owned', 'turn')
|
|
assert store.try_acquire_compression_lock('owned', 'compression')
|
|
rows = [{'role': 'user', 'content': 'accepted', 'api_content': ' original wire ',
|
|
'display_metadata': {'_accepted_input_id': 'input'}}]
|
|
assert store.append_messages_batch('owned', rows, compression_lock_holder='compression',
|
|
turn_lease_holder='turn', turn_lease_ttl_seconds=42) == 1
|
|
assert rows[0]['_row_id'] == db.get_messages_as_conversation('owned', include_row_ids=True)[0]['_row_id']
|
|
assert db.get_messages_as_conversation('owned')[0]['api_content'] == ' original wire '
|
|
import pytest
|
|
from hermes_state_runtime import mutate_worker_execution
|
|
with pytest.raises(Exception, match='lease'):
|
|
mutate_worker_execution(db, **store.scope, sequence=store.journal['next_sequence'],
|
|
operation='compression.append', payload=dict(messages=[{'role': 'assistant', 'content': 'stale'}],
|
|
compression_lock_holder='compression', turn_lease_holder='stale', turn_lease_ttl_seconds=42))
|
|
assert len(db.get_messages('owned')) == 1
|