-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #16632: Add testCases
property to a test suite source config
#16631
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
96 changes: 96 additions & 0 deletions
96
ingestion/tests/unit/data_quality/source/test_test_suite.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
from unittest.mock import Mock | ||
from uuid import UUID | ||
|
||
import pytest | ||
|
||
from metadata.data_quality.source.test_suite import TestSuiteSource | ||
from metadata.generated.schema.entity.data.table import Table | ||
from metadata.generated.schema.metadataIngestion.workflow import ( | ||
OpenMetadataWorkflowConfig, | ||
) | ||
from metadata.generated.schema.tests.testCase import TestCase | ||
from metadata.generated.schema.tests.testSuite import TestSuite | ||
from metadata.generated.schema.type.entityReference import EntityReference | ||
from metadata.ingestion.ometa.ometa_api import OpenMetadata | ||
|
||
MOCK_ENTITY_REFERENCE = EntityReference( | ||
id=str(UUID(int=0)), type="test_suite", name="test_suite" | ||
) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"parameters,expected", | ||
[ | ||
( | ||
{ | ||
"type": "TestSuite", | ||
"entityFullyQualifiedName": "MyTestSuite", | ||
}, | ||
["test_case1", "test_case2"], | ||
), | ||
( | ||
{ | ||
"type": "TestSuite", | ||
"entityFullyQualifiedName": "MyTestSuite", | ||
"testCases": [ | ||
"test_case1", | ||
], | ||
}, | ||
["test_case1"], | ||
), | ||
], | ||
) | ||
def test_source_config(parameters, expected, monkeypatch): | ||
workflow_config = { | ||
"source": { | ||
"type": "TestSuite", | ||
"serviceName": "MyTestSuite", | ||
"sourceConfig": {"config": parameters}, | ||
"serviceConnection": { | ||
"config": { | ||
"type": "Mysql", | ||
"hostPort": "localhost:3306", | ||
"username": "root", | ||
} | ||
}, | ||
}, | ||
"workflowConfig": { | ||
"openMetadataServerConfig": { | ||
"hostPort": "localhost:8585", | ||
} | ||
}, | ||
} | ||
monkeypatch.setattr(TestSuiteSource, "test_connection", Mock()) | ||
|
||
mock_metadata = Mock(spec=OpenMetadata) | ||
mock_metadata.get_by_name.return_value = Table( | ||
id=UUID(int=0), | ||
name="test_table", | ||
columns=[], | ||
testSuite=MOCK_ENTITY_REFERENCE, | ||
) | ||
mock_metadata.list_all_entities.return_value = [ | ||
TestCase( | ||
name="test_case1", | ||
id=UUID(int=0), | ||
testDefinition=MOCK_ENTITY_REFERENCE, | ||
testSuite=MOCK_ENTITY_REFERENCE, | ||
entityLink="<#E::some::link>", | ||
), | ||
TestCase( | ||
name="test_case2", | ||
id=UUID(int=0), | ||
testDefinition=MOCK_ENTITY_REFERENCE, | ||
testSuite=MOCK_ENTITY_REFERENCE, | ||
entityLink="<#E::some::link>", | ||
), | ||
] | ||
mock_metadata.get_by_id.return_value = TestSuite( | ||
name="test_suite", executable=True, id=UUID(int=0) | ||
) | ||
|
||
source = TestSuiteSource( | ||
OpenMetadataWorkflowConfig.parse_obj(workflow_config), mock_metadata | ||
) | ||
test_cases = list(source._iter())[0].right.test_cases | ||
assert [t.name.root for t in test_cases] == expected |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to add an
isDefault
flag to this schema as well. So we can identify the default ingestion pipeline?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
null
value resolves the default behavior. its documented in the description. I'd rather avoid adding this field is it has the potential for ambiguity such as:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. The behavior will be we can have multiple "default" pipelines right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes. this is the same as current behavior. and as we are doing now we can enforce things on the UI side.