Files
wehub-resource-sync bf2343b7e4
Integration Tests - MySQL + Elasticsearch / Detect Changes (push) Has been cancelled
Integration Tests - MySQL + Elasticsearch / integration-tests-mysql-elasticsearch (push) Has been cancelled
Integration Tests - PostgreSQL + Elasticsearch + Redis / Detect Changes (push) Has been cancelled
Integration Tests - PostgreSQL + Elasticsearch + Redis / integration-tests-postgres-elasticsearch-redis (push) Has been cancelled
Integration Tests - PostgreSQL + OpenSearch / Detect Changes (push) Has been cancelled
Integration Tests - PostgreSQL + OpenSearch / integration-tests-postgres-opensearch (push) Has been cancelled
Java Checkstyle / java-checkstyle (push) Has been cancelled
Maven Collate Tests / maven-collate-ci (push) Has been cancelled
OpenMetadata Service Unit Tests / openmetadata-service-unit-tests-status (push) Has been cancelled
Publish Package to Maven Central Repository / publish-maven-packages (push) Has been cancelled
OpenMetadata Service Unit Tests / Detect Changes (push) Has been cancelled
OpenMetadata Service Unit Tests / openmetadata-service-unit-tests (push) Has been cancelled
OpenMetadata Service Unit Tests / k8s_operator-unit-tests (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:35:45 +08:00

72 lines
2.1 KiB
Python

import pytest
from metadata.generated.schema.entity.data.table import Table
from metadata.workflow.metadata import MetadataWorkflow
@pytest.fixture(scope="module")
def prepare_mongodb(mongodbContainer): # noqa: N803
db = mongodbContainer.get_connection_client().test
db.create_collection(
"test_table",
validator={
"$jsonSchema": {
"bsonType": "object",
"required": ["id", "name"],
"properties": {
"id": {
"bsonType": "int",
},
"name": {
"bsonType": "string",
"maxLength": 100,
},
"age": {
"bsonType": "int",
},
},
}
},
)
data = [
{"id": 1, "name": "John Doe", "age": 25},
{"id": 2, "name": "Jane Smith", "age": 30},
]
db.test_table.insert_many(data)
@pytest.mark.parametrize(
"table_fqn,expected_columns",
[
[
"{service}.test.test.test_table",
{
"id": {"type": "int", "nullable": False},
"name": {"type": "string", "nullable": False},
"age": {"type": "int", "nullable": True},
},
]
],
ids=lambda x: x.split(".")[-1] if isinstance(x, str) else "",
)
def test_ingest_metadata(
patch_passwords_for_db_services,
run_workflow,
ingestion_config,
metadata,
table_fqn,
expected_columns,
db_service,
prepare_mongodb,
):
run_workflow(MetadataWorkflow, ingestion_config)
table = metadata.get_by_name(entity=Table, fqn=table_fqn.format(service=db_service.fullyQualifiedName.root))
assert table
assert table.fullyQualifiedName.root.split(".")[-1] == "test_table"
assert len(table.columns) == 4
for name, properties in expected_columns.items():
column = next((col for col in table.columns if col.name.root == name), None)
assert column is not None
assert column.dataType.name.lower() == properties["type"]