mikebridge commented on code in PR #45393: URL: https://github.com/apache/superset/pull/45393#discussion_r4320335438
########## superset-core/tests/semantic_layers/test_registration.py: ########## @@ -0,0 +1,71 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +from typing import get_type_hints + +import pyarrow as pa +import pytest +from superset_core.semantic_layers import decorators +from superset_core.semantic_layers.errors import ( + SemanticQueryErrorCode, + SemanticQueryRejectedError, +) +from superset_core.semantic_layers.layer import ConfigT, SemanticLayer +from superset_core.semantic_layers.types import Dimension + +pytest_plugins: list[str] = ["superset_core.semantic_layers.testing"] + + +def test_configuration_is_part_of_the_typed_contract() -> None: Review Comment: Added in b98da0deb835. The Python unit workflow runs the full `superset-core/tests` suite in a separate SDK step and collects its JUnit results. SDK-only source, test and package changes also trigger the job. All 18 SDK tests pass locally; the new CI run is queued. ########## superset-core/tests/semantic_layers/test_registration.py: ########## @@ -0,0 +1,71 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +from typing import get_type_hints + +import pyarrow as pa +import pytest +from superset_core.semantic_layers import decorators +from superset_core.semantic_layers.errors import ( + SemanticQueryErrorCode, + SemanticQueryRejectedError, +) +from superset_core.semantic_layers.layer import ConfigT, SemanticLayer +from superset_core.semantic_layers.types import Dimension + +pytest_plugins: list[str] = ["superset_core.semantic_layers.testing"] + + +def test_configuration_is_part_of_the_typed_contract() -> None: + """Providers expose their parsed settings under the host's public accessor.""" + assert get_type_hints(SemanticLayer)["configuration"] is ConfigT + + +def test_sdk_only_provider(semantic_layer_registration: None) -> None: + """Import the decorated provider only after the registration fixture starts.""" + from example_provider import ExampleLayer, ExampleView + + layer: ExampleLayer = ExampleLayer.from_configuration({"label": "Example"}) + assert layer.configuration.label == "Example" + assert layer.get_configuration_schema()["properties"]["label"]["type"] == "string" + assert layer.get_runtime_schema(layer.configuration) == { + "type": "object", + "properties": {}, + } + view: ExampleView = layer.get_semantic_view("example", {}) + assert view.uid() == "example" + assert view.get_values(next(iter(view.get_dimensions()))).results.to_pydict() == { + "category": ["A", "B"] + } + assert view.metadata_cache_token is None + + +def test_registration_remains_host_owned() -> None: Review Comment: Fixed in b98da0deb835. The test uses a fresh pytester subprocess with an autouse fixture that captures the original decorator before registration activates and checks identity after teardown. With restoration deliberately broken, the old test passed but the replacement failed at that teardown assertion. With the real fixture restored, the SDK suite passes. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
