40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
from __future__ import annotations
|
|
|
|
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
from alembic.runtime.migration import MigrationContext
|
|
from sqlalchemy import create_engine, inspect
|
|
|
|
from govoplan_connectors.backend.manifest import get_manifest
|
|
from govoplan_core.db.migrations import migrate_database
|
|
|
|
|
|
class ConnectorsMigrationTests(unittest.TestCase):
|
|
def test_baseline_creates_connector_tables_and_head(self) -> None:
|
|
with tempfile.TemporaryDirectory(prefix="govoplan-connectors-migration-") as directory:
|
|
url = f"sqlite:///{Path(directory) / 'connectors.db'}"
|
|
migrate_database(
|
|
database_url=url,
|
|
enabled_modules=("connectors",),
|
|
manifest_factories=(get_manifest,),
|
|
)
|
|
engine = create_engine(url)
|
|
try:
|
|
with engine.connect() as connection:
|
|
self.assertIn(
|
|
"e6b7c8d9f0a1",
|
|
set(MigrationContext.configure(connection).get_current_heads()),
|
|
)
|
|
self.assertIn(
|
|
"connector_tabular_sources",
|
|
inspect(connection).get_table_names(),
|
|
)
|
|
finally:
|
|
engine.dispose()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|