Skip to content

Commit

Permalink
bugfix for get_studio_token_and_repo_url (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
dberenbaum committed May 16, 2023
1 parent b54d601 commit 82744bd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/dvc_studio_client/post_live_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def get_studio_token_and_repo_url(studio_token=None, studio_repo_url=None):
config = get_studio_config(
studio_token=studio_token, studio_repo_url=studio_repo_url
)
return config["token"], config["repo_url"]
return config.get("token"), config.get("repo_url")


def get_studio_config(
Expand Down
15 changes: 15 additions & 0 deletions tests/test_post_live_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
STUDIO_URL,
_get_remote_url,
get_studio_config,
get_studio_token_and_repo_url,
post_live_metrics,
)

Expand Down Expand Up @@ -542,3 +543,17 @@ def test_post_live_metrics_message(mocker, monkeypatch):
},
timeout=5,
)


@pytest.mark.parametrize("var", [DVC_STUDIO_TOKEN, STUDIO_TOKEN])
def test_studio_token_envvar(monkeypatch, var):
monkeypatch.setenv(var, "FOO_TOKEN")
monkeypatch.setenv(STUDIO_REPO_URL, "FOO_REPO_URL")
assert get_studio_token_and_repo_url() == ("FOO_TOKEN", "FOO_REPO_URL")


def test_get_studio_token_and_repo_url_skip_repo_url(monkeypatch):
monkeypatch.setenv(STUDIO_REPO_URL, "FOO_REPO_URL")
token, repo_url = get_studio_token_and_repo_url()
assert token is None
assert repo_url is None # Skipped call to get_repo_url

0 comments on commit 82744bd

Please sign in to comment.