Skip to content
Snippets Groups Projects
Commit aa874a01 authored by Marcin Sobczyk's avatar Marcin Sobczyk
Browse files

Change error message when beekeeper remote address is not set

parent f2d006c5
No related branches found
No related tags found
2 merge requests!555v1.27.5.20 Release,!528msobczyk/346 incorrect message when clive is locked
This commit is part of merge request !555. Comments created here will be created in the context of that merge request.
......@@ -21,10 +21,6 @@ if TYPE_CHECKING:
from clive.__private.core.url import Url
from clive.__private.core.constants.setting_identifiers import BEEKEEPER_REMOTE_ADDRESS, BEEKEEPER_SESSION_TOKEN
from clive.__private.settings import clive_prefixed_envvar
class CLIPrettyError(ClickException):
"""
A pretty error to be shown to the user.
......@@ -197,15 +193,10 @@ class CLIInvalidSelectionError(CLIPrettyError):
class CLIBeekeeperRemoteAddressIsNotSetError(CLIPrettyError):
MESSAGE: Final[str] = "Beekeeper remote address is not set. Please run via start_clive_cli.sh."
def __init__(self) -> None:
token_env_var = clive_prefixed_envvar(BEEKEEPER_SESSION_TOKEN)
address_env_var = clive_prefixed_envvar(BEEKEEPER_REMOTE_ADDRESS)
message = (
f"Beekeeper remote address is not set, you can set it with environment variable `{address_env_var}`"
f" or with setting `{BEEKEEPER_REMOTE_ADDRESS}` in settings file. Variable `{token_env_var}`"
f" or setting `{BEEKEEPER_SESSION_TOKEN}` is also required."
)
super().__init__(message, errno.ENOENT)
super().__init__(self.MESSAGE, errno.EINVAL)
class CLINoProfileUnlockedError(CLIPrettyError):
......
from __future__ import annotations
from typing import TYPE_CHECKING, Final
from typing import TYPE_CHECKING
import pytest
from clive.__private.cli.exceptions import CLIBeekeeperSessionTokenNotSetError
from clive.__private.core.beekeeper.handle import Beekeeper
from clive.__private.cli.exceptions import CLIBeekeeperRemoteAddressIsNotSetError, CLIBeekeeperSessionTokenNotSetError
from clive.__private.core.keys.keys import PrivateKeyAliased
from clive.__private.core.profile import Profile
from clive.__private.core.world import World
......@@ -26,8 +25,7 @@ from clive_local_tools.testnet_block_log import (
if TYPE_CHECKING:
from typing import AsyncGenerator
from _pytest.monkeypatch import MonkeyPatch
from clive.__private.core.beekeeper.handle import Beekeeper
from clive_local_tools.cli.cli_tester import CLITester
from clive_local_tools.types import EnvContextFactory
......@@ -61,15 +59,12 @@ async def cli_tester_without_remote_address(
yield cli_tester
MESSAGE_NO_REMOTE_ADDRESS: Final[str] = "Beekeeper remote address is not set"
async def test_negative_lock_without_remote_address(cli_tester_without_remote_address: CLITester) -> None:
# ARRANGE
# ACT
# ASSERT
with pytest.raises(CLITestCommandError, match=MESSAGE_NO_REMOTE_ADDRESS):
with pytest.raises(CLITestCommandError, match=CLIBeekeeperRemoteAddressIsNotSetError.MESSAGE):
cli_tester_without_remote_address.lock()
......@@ -78,7 +73,7 @@ async def test_negative_unlock_without_remote_address(cli_tester_without_remote_
# ACT
# ASSERT
with pytest.raises(CLITestCommandError, match=MESSAGE_NO_REMOTE_ADDRESS):
with pytest.raises(CLITestCommandError, match=CLIBeekeeperRemoteAddressIsNotSetError.MESSAGE):
cli_tester_without_remote_address.unlock(
profile_name=WORKING_ACCOUNT_NAME, password_stdin=WORKING_ACCOUNT_PASSWORD
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment