Skip to content

Commit

Permalink
Properly reset user agent caching
Browse files Browse the repository at this point in the history
  • Loading branch information
renaudhartert-db committed Jan 21, 2025
1 parent 59bb638 commit 971d869
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 5 additions & 1 deletion tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,16 @@ class MockUname:
def system(self):
return 'TestOS'

# Clear all environment variables and cached CICD provider.
for k in os.environ:
monkeypatch.delenv(k, raising=False)
useragent._cicd_provider = None

monkeypatch.setattr(platform, 'python_version', lambda: '3.0.0')
monkeypatch.setattr(platform, 'uname', MockUname)
monkeypatch.setenv('DATABRICKS_SDK_UPSTREAM', "upstream-product")
monkeypatch.setenv('DATABRICKS_SDK_UPSTREAM_VERSION', "0.0.1")
monkeypatch.setenv('DATABRICKS_RUNTIME_VERSION', "13.1 anything/else")
monkeypatch.delenv('GITHUB_ACTIONS', raising=False)

config = Config(host='http://localhost', username="something", password="something", product='test',
product_version='0.0.0') \
Expand Down
8 changes: 6 additions & 2 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import pytest

from databricks.sdk import WorkspaceClient, errors
from databricks.sdk import WorkspaceClient, errors, useragent
from databricks.sdk.core import ApiClient, Config, DatabricksError
from databricks.sdk.credentials_provider import (CliTokenSource,
CredentialsProvider,
Expand Down Expand Up @@ -178,12 +178,16 @@ class MockUname:
def system(self):
return 'TestOS'

# Clear all environment variables and cached CICD provider.
for k in os.environ:
monkeypatch.delenv(k, raising=False)
useragent._cicd_provider = None

monkeypatch.setattr(platform, 'python_version', lambda: '3.0.0')
monkeypatch.setattr(platform, 'uname', MockUname)
monkeypatch.setenv('DATABRICKS_SDK_UPSTREAM', "upstream-product")
monkeypatch.setenv('DATABRICKS_SDK_UPSTREAM_VERSION', "0.0.1")
monkeypatch.setenv('DATABRICKS_RUNTIME_VERSION', "13.1 anything/else")
monkeypatch.delenv('GITHUB_ACTIONS', raising=False)

config = Config(host='http://localhost', username="something", password="something", product='test',
product_version='0.0.0') \
Expand Down

0 comments on commit 971d869

Please sign in to comment.