feat: add durable store conformance harness

This commit is contained in:
2026-06-16 00:20:29 +02:00
parent 2ceecf6463
commit 886874d0f6
10 changed files with 937 additions and 7 deletions

View File

@@ -0,0 +1,42 @@
import unittest
from user_engine.adapters.local import InMemoryUserEngineStore, SCHEMA_VERSION
from user_engine.migrations import (
LATEST_SCHEMA_VERSION,
USER_ENGINE_RECORD_COUNT_KEYS,
USER_ENGINE_STORE_RECORD_TYPES,
migration_manifest,
validate_migration_manifest,
)
from user_engine.testing.store_conformance import (
assert_user_engine_migration_contract,
assert_user_engine_store_conformance,
)
class DurableStoreConformanceTests(unittest.TestCase):
def test_migration_manifest_is_ordered_and_provider_safe(self):
assert_user_engine_migration_contract(self)
manifest = migration_manifest()
self.assertEqual(validate_migration_manifest(), ())
self.assertEqual(manifest[-1].version, LATEST_SCHEMA_VERSION)
self.assertIn("users", USER_ENGINE_STORE_RECORD_TYPES)
self.assertIn("pending_outbox_events", USER_ENGINE_RECORD_COUNT_KEYS)
def test_local_schema_version_uses_latest_manifest_version(self):
store = InMemoryUserEngineStore()
store.migrate()
self.assertEqual(SCHEMA_VERSION, LATEST_SCHEMA_VERSION)
self.assertEqual(store.schema_version, LATEST_SCHEMA_VERSION)
self.assertTrue(store.ready)
def test_in_memory_store_satisfies_durable_store_contract(self):
assert_user_engine_store_conformance(self, InMemoryUserEngineStore)
if __name__ == "__main__":
unittest.main()