Skip to content

Commit f4db6f4

Browse files
[Internal] Make model serving unit tests a little more hermetic (#906)
## What changes are proposed in this pull request? This PR is a no-op that makes the model serving unit tests a little more hermetic. The solution is not perfect and we will have to consider better ways to enable hermetic tests in the future (which might involve a refactoring of the `Config` object in SDK-Mod). ## How is this tested? N/A NO_CHANGELOG=true
1 parent a646592 commit f4db6f4

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

databricks/sdk/errors/base.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88

99
class ErrorDetail:
10-
1110
def __init__(
1211
self,
1312
type: str = None,

tests/test_model_serving_auth.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,12 @@ def test_model_serving_auth_refresh(monkeypatch, mocker):
162162

163163

164164
def test_agent_user_credentials(monkeypatch, mocker):
165+
# Guarantee that the tests defaults to env variables rather than config file.
166+
#
167+
# TODO: this is hacky and we should find a better way to tell the config
168+
# that it should not read from the config file.
169+
monkeypatch.setenv("DATABRICKS_CONFIG_FILE", "x")
170+
165171
monkeypatch.setenv("IS_IN_DB_MODEL_SERVING_ENV", "true")
166172
monkeypatch.setenv("DB_MODEL_SERVING_HOST_URL", "x")
167173
monkeypatch.setattr(
@@ -205,4 +211,4 @@ def test_agent_user_credentials_in_non_model_serving_environments(monkeypatch):
205211
headers = cfg.authenticate()
206212

207213
assert cfg.host == "https://x"
208-
assert headers.get("Authorization") == f"Bearer token"
214+
assert headers.get("Authorization") == "Bearer token"

0 commit comments

Comments
 (0)