bito-code-review[bot] commented on PR #43534:
URL: https://github.com/apache/superset/pull/43534#issuecomment-5420449110
<!-- Bito Reply -->
The flagged issue is correct. In the current test
`test_impersonate_user_with_token`, the condition `if verify is not None:`
(lines 82-83) prevents the test from passing `verify=None` into `connect_args`.
Consequently, the production code `if "verify" in connect_args:` (line 10 of
`superset/db_engine_specs/trino.py`) is never tested with an explicit `None`
value, which is a distinct case from the key being absent.
To resolve this, you should update the test to explicitly include a case
where `"verify": None` is present in `connect_args` and verify that the
`http_session.verify` is set to `None`.
### Proposed Fix
Modify `tests/unit_tests/db_engine_specs/test_trino.py` to explicitly test
the `None` case:
```python
def test_impersonate_user_with_explicit_none_verify() -> None:
from superset.db_engine_specs.trino import TrinoEngineSpec
url = make_url("trino://host:443/catalog/schema")
engine_kwargs: dict[str, Any] = {"connect_args": {"verify": None}}
_, new_kwargs = TrinoEngineSpec.impersonate_user(
database=MagicMock(),
username="alice",
user_token="user-token",
url=url,
engine_kwargs=engine_kwargs,
)
assert new_kwargs["connect_args"]["http_session"].verify is None
```
There are no other comments on this PR to address.
**tests/unit_tests/db_engine_specs/test_trino.py**
```
def test_impersonate_user_with_explicit_none_verify() -> None:
from superset.db_engine_specs.trino import TrinoEngineSpec
url = make_url("trino://host:443/catalog/schema")
engine_kwargs: dict[str, Any] = {"connect_args": {"verify": None}}
_, new_kwargs = TrinoEngineSpec.impersonate_user(
database=MagicMock(),
username="alice",
user_token="user-token",
url=url,
engine_kwargs=engine_kwargs,
)
assert new_kwargs["connect_args"]["http_session"].verify is None
```
--
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]