fix: url encode fqn when retrieving test case results in python sdk (#23834)

This commit is contained in:
Teddy 2025-10-10 17:25:33 +02:00 committed by GitHub
parent 7b1d687f2d
commit 93e5ee8cb1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 43 additions and 2 deletions

View File

@ -70,6 +70,7 @@ VERSIONS = {
"sqlalchemy-bigquery": "sqlalchemy-bigquery>=1.2.2",
"presidio-analyzer": "presidio-analyzer==2.2.358",
"asammdf": "asammdf~=7.4.5",
"kafka-connect": "kafka-connect-py==0.10.11",
}
COMMONS = {
@ -293,7 +294,7 @@ plugins: Dict[str, Set[str]] = {
"thrift-sasl~=0.4",
},
"kafka": {*COMMONS["kafka"]},
"kafkaconnect": {"kafka-connect-py==0.10.11"},
"kafkaconnect": {VERSIONS["kafka-connect"]},
"kinesis": {VERSIONS["boto3"]},
"looker": {
VERSIONS["looker-sdk"],
@ -464,6 +465,7 @@ test = {
"faker==37.1.0", # The version needs to be fixed to prevent flaky tests!
*plugins["exasol"],
VERSIONS["opensearch"],
VERSIONS["kafka-connect"],
}
if sys.version_info >= (3, 9):

View File

@ -253,7 +253,7 @@ class OMetaTestsMixin:
}
resp = self.client.get(
f"{self.get_suffix(TestCaseResult)}/{test_case_fqn}",
f"{self.get_suffix(TestCaseResult)}/{quote(test_case_fqn)}",
params,
)

View File

@ -128,6 +128,29 @@ class OMetaTestSuiteTest(TestCase):
test_case_fqn="sample_data.ecommerce_db.shopify.dim_address.testCaseForIntegration",
)
# Create test case with special characters in FQN to test URL encoding
cls.metadata.create_or_update(
CreateTestCaseRequest(
name=TestCaseEntityName("testCase:With/Special&Characters"),
entityLink=EntityLink(
"<#E::table::sample_data.ecommerce_db.shopify.dim_address>"
),
testDefinition=cls.test_definition.fullyQualifiedName,
parameterValues=[TestCaseParameterValue(name="foo", value="20")],
)
)
cls.metadata.add_test_case_results(
test_results=TestCaseResult(
timestamp=datetime_to_ts(datetime.now(timezone.utc)),
testCaseStatus=TestCaseStatus.Success,
result="Test Case with special chars Success",
sampleData=None,
testResultValue=[TestResultValue(name="foo", value="20")],
),
test_case_fqn="sample_data.ecommerce_db.shopify.dim_address.testCase:With/Special&Characters",
)
def test_get_or_create_test_suite(self):
"""test we get a test suite object"""
test_suite = self.metadata.get_or_create_test_suite(
@ -187,6 +210,22 @@ class OMetaTestSuiteTest(TestCase):
assert res
def test_get_test_case_results_with_special_characters(self):
"""test get test case results with special characters in FQN (: / &)"""
# This test validates that URL encoding works correctly for FQNs with special chars
res = self.metadata.get_test_case_results(
"sample_data.ecommerce_db.shopify.dim_address.testCase:With/Special&Characters",
get_beginning_of_day_timestamp_mill(),
get_end_of_day_timestamp_mill(),
)
assert (
res is not None
), "Should fetch results for test case with special characters"
assert len(res) > 0, "Should have at least one result"
assert res[0].result == "Test Case with special chars Success"
assert res[0].testCaseStatus == TestCaseStatus.Success
@classmethod
def tearDownClass(cls) -> None:
cls.metadata.delete_executable_test_suite(