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()