diff --git a/helpy/helpy/_communication/rules.py b/helpy/helpy/_communication/rules.py index 531b42ed6c781a637af5f13e26dae7618636608c..5af17469292e2d65c985a1e47c3bc75da61f24a0 100644 --- a/helpy/helpy/_communication/rules.py +++ b/helpy/helpy/_communication/rules.py @@ -27,6 +27,9 @@ if TYPE_CHECKING: from helpy.exceptions import OverseerError +REGEX_FOR_PATH_WITH_CAPTURE_GROUP_ON_WALLET_NAME: Final[str] = r"\/(?:(?:[^\/]+\/)+)([^\/]+)\.wallet" + + class UnableToAcquireDatabaseLock(OverseerRule): LOOKUP_MESSAGE: ClassVar[str] = "Unable to acquire database lock" @@ -236,7 +239,7 @@ class WalletIsAlreadyUnlocked(OverseerRule): class UnableToOpenWallet(OverseerRule): _UNABLE_TO_OPEN_WALLET_REGEX: ClassVar[re.Pattern[str]] = re.compile( r"Assert Exception:_new_item->load_wallet_file\(\): " - r"Unable to open file: (?:\/[\w-]+)+\/([\w-]+\.wallet)(?:rethrow)?" + r"Unable to open file: " + REGEX_FOR_PATH_WITH_CAPTURE_GROUP_ON_WALLET_NAME + r"(?:rethrow)?" ) def _check_single(self, parsed_response: Json, whole_response: Json | list[Json]) -> list[OverseerError]: @@ -253,12 +256,11 @@ class UnableToOpenWallet(OverseerRule): return [] -# - - class InvalidPassword(OverseerRule): _INVALID_PASSWORD_REGEX: ClassVar[re.Pattern[str]] = re.compile( - r"Assert Exception:false: Invalid password for wallet: (?:\/[\w-]+)+\/([\w-]+\.wallet)(?:rethrow)?" + r"Assert Exception:false: Invalid password for wallet: " + + REGEX_FOR_PATH_WITH_CAPTURE_GROUP_ON_WALLET_NAME + + r"(?:rethrow)?" ) def _check_single(self, parsed_response: Json, whole_response: Json | list[Json]) -> list[OverseerError]: diff --git a/tests/beekeepy_test/handle/api_tests/test_api_unlock.py b/tests/beekeepy_test/handle/api_tests/test_api_unlock.py index 918ba1d90c6c9f55967ab25ce9838d21ae7a2589..2794ff92446177d8531d6d2d356c06c0639d68ee 100644 --- a/tests/beekeepy_test/handle/api_tests/test_api_unlock.py +++ b/tests/beekeepy_test/handle/api_tests/test_api_unlock.py @@ -86,5 +86,5 @@ def test_api_unlock_with_invalid_password(beekeeper: Beekeeper, setup_wallets: W wallet = setup_wallets(1, keys_per_wallet=0)[0] # ASSERT - with pytest.raises(InvalidPasswordError, match="Invalid password for wallet: wallet-0.wallet"): + with pytest.raises(InvalidPasswordError, match="Invalid password for wallet: wallet-0"): beekeeper.api.unlock(wallet_name=wallet.name, password="invalid password") # noqa: S106