bito-code-review[bot] commented on code in PR #43256: URL: https://github.com/apache/superset/pull/43256#discussion_r3797122776
########## tests/unit_tests/views/test_custom_tags_api_mixin.py: ########## @@ -0,0 +1,43 @@ +# 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 marshmallow import fields, Schema + +from superset.views.custom_tags_api_mixin import CustomTagsOptimizationMixin + + +class BaseApi: + list_model_schema: Schema + + def _init_model_schemas(self) -> None: + self.list_model_schema = Schema.from_dict( + {"custom_tags": fields.List(fields.String())} + )() + + +class CustomTagsApi(CustomTagsOptimizationMixin, BaseApi): + _custom_tags_only = True + + +def test_custom_tags_schema_uses_public_tags_name() -> None: + api = CustomTagsApi() + + api._init_model_schemas() + + assert api.list_model_schema.dump({"custom_tags": ["critical"]}) == { + "tags": ["critical"] + } Review Comment: <div> <div id="suggestion"> <div id="issue"><b>Incomplete test coverage for mixin behavior</b></div> <div id="fix"> The mixin has two separate renaming mechanisms: `_init_model_schemas` (schema-level `data_key`) and `pre_get_list` (response-level key mutation at lines 113-116). This test only covers the schema mechanism, leaving the `pre_get_list` code path (which handles the actual API response transformation) completely untested. Rule [11730] requires tests covering both success paths and edge cases. </div> </div> <small><i>Code Review Run #690a40</i></small> </div> --- Should Bito avoid suggestions like this for future reviews? (<a href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>) - [ ] Yes, avoid them -- 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]
