refactor: retain workflow as optional editor
This commit is contained in:
+13
-39
@@ -2,57 +2,31 @@ from __future__ import annotations
|
||||
|
||||
import unittest
|
||||
|
||||
from govoplan_workflow.backend.manifest import (
|
||||
DEFINITION_READ_SCOPE,
|
||||
DEFINITION_WRITE_SCOPE,
|
||||
INSTANCE_START_SCOPE,
|
||||
get_manifest,
|
||||
)
|
||||
from govoplan_core.core.workflows import (
|
||||
CAPABILITY_WORKFLOW_RUNTIME_WORKER,
|
||||
)
|
||||
from govoplan_workflow.backend.manifest import get_manifest
|
||||
|
||||
|
||||
class WorkflowManifestTests(unittest.TestCase):
|
||||
def test_manifest_exposes_definition_contracts(self) -> None:
|
||||
def test_manifest_is_an_editor_only_engine_client(self) -> None:
|
||||
manifest = get_manifest()
|
||||
|
||||
self.assertEqual(manifest.id, "workflow")
|
||||
self.assertEqual("workflow", manifest.id)
|
||||
self.assertEqual(("workflow_engine",), manifest.dependencies)
|
||||
self.assertEqual(
|
||||
{"workflow.definition_graph", "workflow.definition_catalogue", "workflow.bpmn_interchange"},
|
||||
{item.name for item in manifest.requires_interfaces},
|
||||
)
|
||||
self.assertIn(
|
||||
"workflow.definition_graph",
|
||||
"workflow.editor",
|
||||
{item.name for item in manifest.provides_interfaces},
|
||||
)
|
||||
self.assertIn(
|
||||
DEFINITION_READ_SCOPE,
|
||||
{item.scope for item in manifest.permissions},
|
||||
)
|
||||
self.assertIn(
|
||||
DEFINITION_WRITE_SCOPE,
|
||||
{item.scope for item in manifest.permissions},
|
||||
)
|
||||
self.assertIn(
|
||||
INSTANCE_START_SCOPE,
|
||||
{item.scope for item in manifest.permissions},
|
||||
)
|
||||
self.assertIn(
|
||||
"workflow.runtime_worker",
|
||||
{item.name for item in manifest.provides_interfaces},
|
||||
)
|
||||
self.assertIn(
|
||||
CAPABILITY_WORKFLOW_RUNTIME_WORKER,
|
||||
manifest.capability_factories,
|
||||
)
|
||||
self.assertEqual((), manifest.permissions)
|
||||
self.assertIsNone(manifest.route_factory)
|
||||
self.assertIsNone(manifest.migration_spec)
|
||||
self.assertEqual({}, manifest.capability_factories)
|
||||
self.assertEqual(
|
||||
"@govoplan/workflow-webui",
|
||||
manifest.frontend.package_name if manifest.frontend else None,
|
||||
)
|
||||
self.assertIsNotNone(manifest.migration_spec)
|
||||
requirement = next(
|
||||
item
|
||||
for item in manifest.requires_interfaces
|
||||
if item.name == "dataflow.run_lifecycle"
|
||||
)
|
||||
self.assertTrue(requirement.optional)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -1,76 +1,13 @@
|
||||
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_core.db.migrations import migrate_database
|
||||
from govoplan_workflow.backend.manifest import get_manifest
|
||||
|
||||
|
||||
class WorkflowMigrationTests(unittest.TestCase):
|
||||
def test_migration_creates_definition_tables_and_head(self) -> None:
|
||||
with tempfile.TemporaryDirectory(
|
||||
prefix="govoplan-workflow-migration-"
|
||||
) as directory:
|
||||
url = f"sqlite:///{Path(directory) / 'workflow.db'}"
|
||||
migrate_database(
|
||||
database_url=url,
|
||||
enabled_modules=("workflow",),
|
||||
manifest_factories=(get_manifest,),
|
||||
)
|
||||
engine = create_engine(url)
|
||||
try:
|
||||
with engine.connect() as connection:
|
||||
self.assertIn(
|
||||
"f1b7d3e5a9c2",
|
||||
set(MigrationContext.configure(connection).get_current_heads()),
|
||||
)
|
||||
self.assertEqual(
|
||||
{
|
||||
"workflow_definition_revisions",
|
||||
"workflow_definitions",
|
||||
"workflow_instance_events",
|
||||
"workflow_instance_steps",
|
||||
"workflow_instances",
|
||||
},
|
||||
{
|
||||
name
|
||||
for name in inspect(connection).get_table_names()
|
||||
if name.startswith("workflow_")
|
||||
},
|
||||
)
|
||||
revision_columns = {
|
||||
item["name"]
|
||||
for item in inspect(connection).get_columns(
|
||||
"workflow_definition_revisions"
|
||||
)
|
||||
}
|
||||
self.assertTrue(
|
||||
{
|
||||
"bpmn_xml",
|
||||
"bpmn_hash",
|
||||
"bpmn_adapter_id",
|
||||
"bpmn_adapter_version",
|
||||
"bpmn_runtime_kind",
|
||||
"bpmn_executable",
|
||||
"execution_mode",
|
||||
"view_id",
|
||||
"view_revision_id",
|
||||
}.issubset(revision_columns)
|
||||
)
|
||||
instance_columns = {
|
||||
item["name"]
|
||||
for item in inspect(connection).get_columns(
|
||||
"workflow_instances"
|
||||
)
|
||||
}
|
||||
self.assertIn("start_origin", instance_columns)
|
||||
finally:
|
||||
engine.dispose()
|
||||
class WorkflowEditorMigrationTests(unittest.TestCase):
|
||||
def test_editor_does_not_own_database_migrations(self) -> None:
|
||||
self.assertIsNone(get_manifest().migration_spec)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user