Implement governed voting module
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
from alembic.runtime.migration import MigrationContext
|
||||
from sqlalchemy import create_engine, inspect
|
||||
|
||||
from govoplan_core.db.migrations import migrate_database
|
||||
from govoplan_voting.backend.manifest import get_manifest
|
||||
|
||||
|
||||
class VotingMigrationTests(unittest.TestCase):
|
||||
def test_fresh_migration_creates_voting_runtime_tables(self) -> None:
|
||||
with tempfile.TemporaryDirectory(prefix="govoplan-voting-") as directory:
|
||||
url = f"sqlite:///{Path(directory) / 'voting.db'}"
|
||||
migrate_database(
|
||||
database_url=url,
|
||||
enabled_modules=("voting",),
|
||||
manifest_factories=(get_manifest,),
|
||||
)
|
||||
engine = create_engine(url)
|
||||
try:
|
||||
tables = set(inspect(engine).get_table_names())
|
||||
self.assertTrue(
|
||||
{
|
||||
"voting_ballot_revisions",
|
||||
"voting_cast_records",
|
||||
"voting_lifecycle_events",
|
||||
"voting_command_replays",
|
||||
}.issubset(tables)
|
||||
)
|
||||
with engine.connect() as connection:
|
||||
self.assertIn(
|
||||
"7a8b9c0d1e2f",
|
||||
set(MigrationContext.configure(connection).get_current_heads()),
|
||||
)
|
||||
finally:
|
||||
engine.dispose()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user