Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kenodegard committed Oct 20, 2023
1 parent 0a1b490 commit df23763
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions tests/cli/test_group.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from conda_auth.cli import auth_wrapper
from conda_auth.cli import auth


def test_auth_wrapper():
Expand All @@ -11,4 +11,4 @@ def test_auth_wrapper():
exception.
"""
with pytest.raises(SystemExit):
auth_wrapper([])
auth([])
20 changes: 10 additions & 10 deletions tests/cli/test_login.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from conda_auth.cli import group, SUCCESSFUL_LOGIN_MESSAGE
from conda_auth.cli import auth, SUCCESSFUL_LOGIN_MESSAGE
from conda_auth.condarc import CondaRCError
from conda_auth.exceptions import CondaAuthError

Expand All @@ -16,7 +16,7 @@ def test_login_basic_auth_no_options(runner, keyring, condarc):

# run command
result = runner.invoke(
group, ["login", channel_name, "--basic"], input=f"{username}\n{secret}"
auth, ["login", channel_name, "--basic"], input=f"{username}\n{secret}"
)

assert result.exit_code == 0
Expand All @@ -34,7 +34,7 @@ def test_login_with_options_basic_auth(runner, keyring, condarc):

# run command
result = runner.invoke(
group,
auth,
["login", channel_name, "--basic", "--username", "test", "--password", "test"],
)

Expand All @@ -52,12 +52,12 @@ def test_login_with_invalid_auth_type(runner, keyring, condarc):
keyring(None)

# run command
result = runner.invoke(group, ["login", channel_name])
result = runner.invoke(auth, ["login", channel_name])
exc_type, exception, _ = result.exc_info

assert result.exit_code == 1
assert exc_type == CondaAuthError
assert "Please specify an authentication type" in exception.message
assert result.exit_code == 2
assert exc_type == SystemExit
assert "Error: Missing option 'basic' / 'token'." in result.stdout


def test_login_succeeds_error_returned_when_updating_condarc(runner, keyring, condarc):
Expand All @@ -73,7 +73,7 @@ def test_login_succeeds_error_returned_when_updating_condarc(runner, keyring, co

# run command
result = runner.invoke(
group, ["login", channel_name, "--basic"], input="user\npassword"
auth, ["login", channel_name, "--basic"], input="user\npassword"
)
exc_type, exception, _ = result.exc_info

Expand All @@ -92,7 +92,7 @@ def test_login_token(mocker, runner, keyring, condarc):
mock_context.channel_settings = []
keyring(None)

result = runner.invoke(group, ["login", channel_name, "--token", "token"])
result = runner.invoke(auth, ["login", channel_name, "--token", "token"])

assert result.exit_code == 0

Expand All @@ -106,7 +106,7 @@ def test_login_token_no_options(runner, keyring, condarc):
# setup mocks
keyring(None)

result = runner.invoke(group, ["login", channel_name, "--token"], input="token\n")
result = runner.invoke(auth, ["login", channel_name, "--token"], input="token\n")

assert result.exit_code == 0
assert SUCCESSFUL_LOGIN_MESSAGE in result.output
6 changes: 3 additions & 3 deletions tests/cli/test_logout.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from conda_auth.cli import group, SUCCESSFUL_LOGOUT_MESSAGE
from conda_auth.cli import auth, SUCCESSFUL_LOGOUT_MESSAGE
from conda_auth.constants import PLUGIN_NAME
from conda_auth.handlers.basic_auth import HTTP_BASIC_AUTH_NAME
from conda_auth.exceptions import CondaAuthError
Expand All @@ -20,7 +20,7 @@ def test_logout_of_active_session(mocker, runner, keyring):
]

# run command
result = runner.invoke(group, ["logout", channel_name])
result = runner.invoke(auth, ["logout", channel_name])

assert SUCCESSFUL_LOGOUT_MESSAGE in result.output
assert result.exit_code == 0
Expand All @@ -43,7 +43,7 @@ def test_logout_of_non_existing_session(mocker, runner, keyring):
mock_context.channel_settings = []

# run command
result = runner.invoke(group, ["logout", channel_name])
result = runner.invoke(auth, ["logout", channel_name])
exc_type, exception, _ = result.exc_info

assert exc_type == CondaAuthError
Expand Down
10 changes: 5 additions & 5 deletions tests/test_hooks.py → tests/test_plugin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from conda.cli.conda_argparse import BUILTIN_COMMANDS

from conda_auth import hooks
from conda_auth import plugin
from conda_auth.constants import PLUGIN_NAME
from conda_auth.handlers import (
HTTP_BASIC_AUTH_NAME,
Expand All @@ -14,7 +14,7 @@ def test_conda_subcommands_hook():
"""
Test to make sure that this hook yields the correct objects.
"""
objs = list(hooks.conda_subcommands())
objs = list(plugin.conda_subcommands())

assert objs[0].name == "auth"
assert objs[0].summary == "Authentication commands for conda"
Expand All @@ -24,9 +24,9 @@ def test_conda_pre_commands_hook():
"""
Test to make sure that this hook yields the correct objects.
"""
objs = list(hooks.conda_pre_commands())
objs = list(plugin.conda_pre_commands())

run_for = BUILTIN_COMMANDS.union(hooks.ENV_COMMANDS)
run_for = BUILTIN_COMMANDS.union(plugin.ENV_COMMANDS)

assert objs[0].name == f"{PLUGIN_NAME}-{HTTP_BASIC_AUTH_NAME}"
assert objs[0].run_for == run_for
Expand All @@ -39,7 +39,7 @@ def test_conda_auth_handlers_hook():
"""
Test to make sure that this hook yields the correct objects.
"""
objs = list(hooks.conda_auth_handlers())
objs = list(plugin.conda_auth_handlers())

assert objs[0].name == HTTP_BASIC_AUTH_NAME
assert objs[0].handler == BasicAuthHandler
Expand Down

0 comments on commit df23763

Please sign in to comment.