Skip to content

Commit d9c6da2

Browse files
committed
feat: cover governance workflow and insight APIs
1 parent d21ef97 commit d9c6da2

3 files changed

Lines changed: 103 additions & 2 deletions

File tree

platform-api/src/openmetadata_demo_api/catalog.py

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,23 @@
5555
"createDBSchema",
5656
"createTable",
5757
}
58+
GOVERNANCE_INSIGHT_PREFIXES = (
59+
"governance/",
60+
"analytics/",
61+
"datainsight/",
62+
"kpi/",
63+
"reports/",
64+
)
65+
GOVERNANCE_PARENT_FILES = {
66+
"datainsight/DataInsightChartResource.java",
67+
"datainsight/system/DataInsightSystemChartResource.java",
68+
"governance/WorkflowDefinitionResource.java",
69+
}
70+
GOVERNANCE_CHILD_FILES = {
71+
"governance/WorkflowInstanceResource.java",
72+
"kpi/KpiResource.java",
73+
}
74+
GOVERNANCE_LEAF_FILES = {"governance/WorkflowInstanceStateResource.java"}
5875
CORE_SERVICE_PREREQUISITES = {
5976
"createApiService",
6077
"createDashboardService",
@@ -243,10 +260,12 @@ def _phase(operation: Mapping[str, Any]) -> str:
243260
term in operation_text for term in DEPENDENT_RECORD_TERMS
244261
):
245262
return "enrichment"
246-
if source_file in CORE_PARENT_FILES | TAXONOMY_PARENT_FILES:
263+
if source_file in CORE_PARENT_FILES | TAXONOMY_PARENT_FILES | GOVERNANCE_PARENT_FILES:
247264
return "parent-assets"
248-
if source_file in CORE_CHILD_FILES | TAXONOMY_CHILD_FILES:
265+
if source_file in CORE_CHILD_FILES | TAXONOMY_CHILD_FILES | GOVERNANCE_CHILD_FILES:
249266
return "child-assets"
267+
if source_file in GOVERNANCE_LEAF_FILES:
268+
return "leaf-assets"
250269
if source_file.startswith(CORE_PREFIXES):
251270
return "leaf-assets"
252271
if source_file.startswith(ENRICHMENT_PREFIXES):
@@ -359,6 +378,16 @@ def scenarios() -> dict[str, Scenario]:
359378
or operation["operation_id"] in CONTRACT_ASSET_PREREQUISITES
360379
),
361380
),
381+
"governance-insights": scenario_from_operations(
382+
"governance-insights",
383+
"Governance workflows, analytics, insights, KPIs, reports, and forms",
384+
tuple(
385+
operation
386+
for operation in all_operations
387+
if str(operation["source"]["file"]).startswith(GOVERNANCE_INSIGHT_PREFIXES)
388+
or operation["operation_id"] == "createDashboardService"
389+
),
390+
),
362391
}
363392

364393

platform-api/src/openmetadata_demo_api/request_fixtures.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,18 @@
159159
"userComments": "Dry-run review",
160160
},
161161
"ReactionType": "thumbsUp",
162+
"Report": {
163+
"id": DEMO_ID,
164+
"name": "demo-report",
165+
"fullyQualifiedName": "demo.demo-report",
166+
"service": {
167+
"id": DEMO_ID,
168+
"type": "dashboardService",
169+
"name": "demo",
170+
"fullyQualifiedName": "demo",
171+
},
172+
},
173+
"ReportData": {"timestamp": 1, "reportDataType": "entityReportData"},
162174
"ReportDataType": "entityReportData",
163175
"RestoreEntity": {"id": DEMO_ID},
164176
"SearchIndexSampleData": {"messages": ['{"id": 1}']},
@@ -192,6 +204,7 @@
192204
},
193205
"ValidateGlossaryTagsRequest": {"dryRun": True, "glossaryTags": []},
194206
"VoteRequest": {"updatedVoteType": "votedUp"},
207+
"WebAnalyticEventData": {"timestamp": 1, "eventType": "PageView"},
195208
"WebAnalyticEventType": "PageView",
196209
}
197210
)
@@ -277,6 +290,8 @@
277290
"metadata.generated.schema.type.recognizerFeedback",
278291
"RecognizerFeedback",
279292
),
293+
"Report": ("metadata.generated.schema.entity.data.report", "Report"),
294+
"ReportData": ("metadata.generated.schema.analytics.reportData", "ReportData"),
280295
"RestoreEntity": (
281296
"metadata.generated.schema.api.data.restoreEntity",
282297
"RestoreEntity",
@@ -309,6 +324,10 @@
309324
"ValidateGlossaryTagsRequest",
310325
),
311326
"VoteRequest": ("metadata.generated.schema.api.voteRequest", "QueryVote"),
327+
"WebAnalyticEventData": (
328+
"metadata.generated.schema.analytics.webAnalyticEventData",
329+
"WebAnalyticEventData",
330+
),
312331
}
313332
)
314333

platform-api/tests/test_runtime.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,3 +800,56 @@ def test_contract_policy_knowledge_requests_are_validated_and_placeholder_free()
800800
"CreateLearningResourceRequest",
801801
"CreateDocumentRequest",
802802
} <= models
803+
804+
805+
def test_governance_insight_scenario_covers_source_routes_and_dependencies() -> None:
806+
prefixes = ("governance/", "analytics/", "datainsight/", "kpi/", "reports/")
807+
expected = {
808+
operation["operation_id"]
809+
for operation in load_operations()
810+
if str(operation["source"]["file"]).startswith(prefixes)
811+
}
812+
scenario = scenarios()["governance-insights"]
813+
814+
assert {step.operation_id for step in scenario.operation_steps} == expected | {
815+
"createDashboardService"
816+
}
817+
assert len(scenario.run()) == len(expected) + 1
818+
assert {
819+
"createWebAnalyticEventType",
820+
"addReportData",
821+
"createDataInsightChart",
822+
"createIntakeForm",
823+
"createWorkflowDefinition",
824+
"createKpi",
825+
"createOrUpdateReport",
826+
} <= expected
827+
ordered = [step.operation_id for step in scenario.ordered_steps()]
828+
assert ordered.index("createWorkflowDefinition") < ordered.index("listWorkflowInstances")
829+
assert ordered.index("listWorkflowInstances") < ordered.index("listWorkflowInstanceStates")
830+
assert ordered.index("createDataInsightChart") < ordered.index("createKpi")
831+
assert ordered.index("createDashboardService") < ordered.index("createOrUpdateReport")
832+
833+
834+
def test_governance_insight_requests_are_validated_and_placeholder_free() -> None:
835+
scenario = scenarios()["governance-insights"]
836+
837+
assert not {
838+
str(value["_model"])
839+
for step in scenario.operation_steps
840+
for value in _nested_mappings(step.request)
841+
if "_model" in value
842+
}
843+
models = {
844+
str(asset["model"]).rsplit(".", 1)[-1]
845+
for asset in load_assets()
846+
if "governance-insights" in asset["scenarios"]
847+
}
848+
assert {
849+
"CreateWebAnalyticEvent",
850+
"CreateDataInsightChart",
851+
"CreateKpiRequest",
852+
"CreateIntakeFormRequest",
853+
"CreateWorkflowDefinitionRequest",
854+
"CreateWorkflowInstanceStateRequest",
855+
} <= models

0 commit comments

Comments
 (0)