Skip to content

Commit

Permalink
style: beautify 26528eb
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Dec 22, 2023
1 parent 26528eb commit 514f558
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions tests/unit/semantic_release/cli/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,32 @@
from typing import Any


@pytest.mark.parametrize("remote_config, expected_token", [
({ "type": HvcsClient.GITHUB.value }, EnvConfigVar(env="GH_TOKEN")),
({ "type": HvcsClient.GITLAB.value }, EnvConfigVar(env="GITLAB_TOKEN")),
({ "type": HvcsClient.GITEA.value }, EnvConfigVar(env="GITEA_TOKEN")),
({}, EnvConfigVar(env="GH_TOKEN")), # default not provided -> means Github
])
@pytest.mark.parametrize(
"remote_config, expected_token",
[
({"type": HvcsClient.GITHUB.value}, EnvConfigVar(env="GH_TOKEN")),
({"type": HvcsClient.GITLAB.value}, EnvConfigVar(env="GITLAB_TOKEN")),
({"type": HvcsClient.GITEA.value}, EnvConfigVar(env="GITEA_TOKEN")),
({}, EnvConfigVar(env="GH_TOKEN")), # default not provided -> means Github
],
)
def test_load_hvcs_default_token(remote_config: dict[str, Any], expected_token):
raw_config = RawConfig.model_validate({
"remote": remote_config,
})
raw_config = RawConfig.model_validate(
{
"remote": remote_config,
}
)
assert expected_token == raw_config.remote.token


@pytest.mark.parametrize("remote_config", [
{ "type": "nonexistent" }
])
@pytest.mark.parametrize("remote_config", [{"type": "nonexistent"}])
def test_invalid_hvcs_type(remote_config: dict[str, Any]):
with pytest.raises(ValidationError) as excinfo:
RawConfig.model_validate({
"remote": remote_config,
})
RawConfig.model_validate(
{
"remote": remote_config,
}
)
assert "remote.type" in str(excinfo.value)


Expand Down

0 comments on commit 514f558

Please sign in to comment.