From f5cd6a195407a735e9c558d98b0194cc4121a84d Mon Sep 17 00:00:00 2001 From: Vladimir Domnich Date: Fri, 23 Sep 2022 10:12:04 +0400 Subject: [PATCH] [#3] Move source code of testlib to src directory Signed-off-by: Vladimir Domnich --- README.md | 33 +++++++++++++- cli/__init__.py | 3 -- cli/adm/__init__.py | 1 - cli/authmate/__init__.py | 1 - cli/go/__init__.py | 2 - shell/__init__.py | 3 -- src/neofs_testlib/cli/__init__.py | 3 ++ {cli => src/neofs_testlib/cli}/cli_command.py | 14 +++--- src/neofs_testlib/cli/neofs_adm/__init__.py | 1 + .../neofs_testlib/cli/neofs_adm}/adm.py | 14 +++--- .../neofs_testlib/cli/neofs_adm}/config.py | 8 ++-- .../neofs_testlib/cli/neofs_adm}/morph.py | 26 ++++++++--- .../cli/neofs_adm}/storage_config.py | 8 ++-- .../neofs_testlib/cli/neofs_adm}/subnet.py | 28 ++++++------ .../neofs_testlib/cli/neofs_adm}/version.py | 6 +-- .../cli/neofs_authmate/__init__.py | 1 + .../cli/neofs_authmate}/authmate.py | 14 ++---- .../cli/neofs_authmate}/secret.py | 24 +++++------ .../cli/neofs_authmate}/version.py | 6 +-- src/neofs_testlib/cli/neogo/__init__.py | 2 + .../neofs_testlib/cli/neogo}/candidate.py | 36 ++++++++-------- .../neofs_testlib/cli/neogo}/contract.py | 21 +++++---- {cli/go => src/neofs_testlib/cli/neogo}/db.py | 43 +++++++++---------- {cli/go => src/neofs_testlib/cli/neogo}/go.py | 29 +++++-------- .../neofs_testlib/cli/neogo}/nep17.py | 23 +++++----- .../neofs_testlib/cli/neogo/network_type.py | 0 .../neofs_testlib/cli/neogo}/node.py | 9 ++-- .../neofs_testlib/cli/neogo}/query.py | 8 ++-- .../neofs_testlib/cli/neogo}/version.py | 6 +-- .../neofs_testlib/cli/neogo}/wallet.py | 31 +++++++------ .../neofs_testlib/reporter}/__init__.py | 6 +-- .../reporter}/allure_reporter.py | 2 +- .../neofs_testlib/reporter}/dummy_reporter.py | 2 +- .../neofs_testlib/reporter}/interfaces.py | 0 src/neofs_testlib/shell/__init__.py | 3 ++ .../neofs_testlib/shell}/interfaces.py | 0 .../neofs_testlib/shell}/local_shell.py | 4 +- .../neofs_testlib/shell}/ssh_shell.py | 4 +- tests/helpers.py | 2 +- tests/test_local_shell.py | 5 ++- tests/test_ssh_shell.py | 5 ++- 41 files changed, 230 insertions(+), 207 deletions(-) delete mode 100644 cli/__init__.py delete mode 100644 cli/adm/__init__.py delete mode 100644 cli/authmate/__init__.py delete mode 100644 cli/go/__init__.py delete mode 100644 shell/__init__.py create mode 100644 src/neofs_testlib/cli/__init__.py rename {cli => src/neofs_testlib/cli}/cli_command.py (80%) create mode 100644 src/neofs_testlib/cli/neofs_adm/__init__.py rename {cli/adm => src/neofs_testlib/cli/neofs_adm}/adm.py (68%) rename {cli/adm => src/neofs_testlib/cli/neofs_adm}/config.py (77%) rename {cli/adm => src/neofs_testlib/cli/neofs_adm}/morph.py (95%) rename {cli/adm => src/neofs_testlib/cli/neofs_adm}/storage_config.py (76%) rename {cli/adm => src/neofs_testlib/cli/neofs_adm}/subnet.py (94%) rename {cli/authmate => src/neofs_testlib/cli/neofs_adm}/version.py (57%) create mode 100644 src/neofs_testlib/cli/neofs_authmate/__init__.py rename {cli/authmate => src/neofs_testlib/cli/neofs_authmate}/authmate.py (54%) rename {cli/authmate => src/neofs_testlib/cli/neofs_authmate}/secret.py (90%) rename {cli/adm => src/neofs_testlib/cli/neofs_authmate}/version.py (56%) create mode 100644 src/neofs_testlib/cli/neogo/__init__.py rename {cli/go => src/neofs_testlib/cli/neogo}/candidate.py (84%) rename {cli/go => src/neofs_testlib/cli/neogo}/contract.py (95%) rename {cli/go => src/neofs_testlib/cli/neogo}/db.py (69%) rename {cli/go => src/neofs_testlib/cli/neogo}/go.py (60%) rename {cli/go => src/neofs_testlib/cli/neogo}/nep17.py (96%) rename cli/go/blockchain_network_type.py => src/neofs_testlib/cli/neogo/network_type.py (100%) rename {cli/go => src/neofs_testlib/cli/neogo}/node.py (63%) rename {cli/go => src/neofs_testlib/cli/neogo}/query.py (95%) rename {cli/go => src/neofs_testlib/cli/neogo}/version.py (57%) rename {cli/go => src/neofs_testlib/cli/neogo}/wallet.py (97%) rename {reporter => src/neofs_testlib/reporter}/__init__.py (64%) rename {reporter => src/neofs_testlib/reporter}/allure_reporter.py (95%) rename {reporter => src/neofs_testlib/reporter}/dummy_reporter.py (88%) rename {reporter => src/neofs_testlib/reporter}/interfaces.py (100%) create mode 100644 src/neofs_testlib/shell/__init__.py rename {shell => src/neofs_testlib/shell}/interfaces.py (100%) rename {shell => src/neofs_testlib/shell}/local_shell.py (98%) rename {shell => src/neofs_testlib/shell}/ssh_shell.py (98%) diff --git a/README.md b/README.md index e4930424..995c9463 100644 --- a/README.md +++ b/README.md @@ -47,4 +47,35 @@ SSH_SHELL_HOST =
SSH_SHELL_LOGIN = SSH_SHELL_PRIVATE_KEY_PATH = SSH_SHELL_PRIVATE_KEY_PASSPHRASE = -``` \ No newline at end of file +``` + +### Editable installation +If you would like to modify code of the library in the integration with your test suite, you can use editable installation. For that, in virtual environment of your test suite (not in the virtual environment of the testlib itself!) run the following command (path to `neofs-testlib` directory might be different on your machine): +```shell +$ pip install -e ../neofs-testlib +``` + +### Building and publishing package +To build Python package of the library, please run the following command in the library root directory: +```shell +$ python -m build +``` + +This command will put wheel file and source archive under `dist` directory. + +To check that package description will be correctly rendered at PyPI, please, use command: +```shell +$ twine check dist/* +``` + +To upload package to [test PyPI](https://test.pypi.org/project/neofs-testlib/), please, use command: +```shell +$ twine upload -r testpypi dist/* +``` +It will prompt for your username and password. You would need to [create test PyPI account](https://test.pypi.org/account/register/) in order to execute it. + +To upload package to actual PyPI, please, use command: +```shell +$ twine upload dist/* +``` +It will prompt for your username and password. You would need to [create account](https://pypi.org/account/register/) in order to execute it. diff --git a/cli/__init__.py b/cli/__init__.py deleted file mode 100644 index 112c15bb..00000000 --- a/cli/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from .adm import NeofsAdm -from .authmate import NeofsAuthmate -from .go import NeoGo, NetworkType diff --git a/cli/adm/__init__.py b/cli/adm/__init__.py deleted file mode 100644 index 1596cb35..00000000 --- a/cli/adm/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .adm import NeofsAdm diff --git a/cli/authmate/__init__.py b/cli/authmate/__init__.py deleted file mode 100644 index 112b6a97..00000000 --- a/cli/authmate/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .authmate import NeofsAuthmate diff --git a/cli/go/__init__.py b/cli/go/__init__.py deleted file mode 100644 index d3fa1937..00000000 --- a/cli/go/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -from .blockchain_network_type import NetworkType -from .go import NeoGo diff --git a/shell/__init__.py b/shell/__init__.py deleted file mode 100644 index b867f00e..00000000 --- a/shell/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from .interfaces import CommandResult, Shell -from .local_shell import LocalShell -from .ssh_shell import SSHShell diff --git a/src/neofs_testlib/cli/__init__.py b/src/neofs_testlib/cli/__init__.py new file mode 100644 index 00000000..27ffbc22 --- /dev/null +++ b/src/neofs_testlib/cli/__init__.py @@ -0,0 +1,3 @@ +from neofs_testlib.cli.neofs_adm.adm import NeofsAdm +from neofs_testlib.cli.neofs_authmate.authmate import NeofsAuthmate +from neofs_testlib.cli.neogo.go import NeoGo diff --git a/cli/cli_command.py b/src/neofs_testlib/cli/cli_command.py similarity index 80% rename from cli/cli_command.py rename to src/neofs_testlib/cli/cli_command.py index a622324c..13268f26 100644 --- a/cli/cli_command.py +++ b/src/neofs_testlib/cli/cli_command.py @@ -1,13 +1,13 @@ from typing import Optional -from shell import CommandResult, Shell +from neofs_testlib.shell import CommandResult, Shell -class NeofsCliCommand: +class CliCommand: - WALLET_SOURCE_ERROR_MSG = 'Provide either wallet or wallet_config to specify wallet location' + WALLET_SOURCE_ERROR_MSG = "Provide either wallet or wallet_config to specify wallet location" - neofs_cli_exec: Optional[str] = None + cli_exec_path: Optional[str] = None __base_params: Optional[str] = None map_params = { "json_mode": "json", @@ -16,9 +16,9 @@ class NeofsCliCommand: "doc_type": "type", } - def __init__(self, shell: Shell, neofs_cli_exec: str, **base_params): + def __init__(self, shell: Shell, cli_exec_path: str, **base_params): self.shell = shell - self.neofs_cli_exec = neofs_cli_exec + self.cli_exec_path = cli_exec_path self.__base_params = " ".join( [f"--{param} {value}" for param, value in base_params.items() if value] ) @@ -52,7 +52,7 @@ class NeofsCliCommand: param_str = " ".join(param_str) - return f'{self.neofs_cli_exec} {self.__base_params} {command or ""} {param_str}' + return f"{self.cli_exec_path} {self.__base_params} {command or ''} {param_str}" def _execute(self, command: Optional[str], **params) -> CommandResult: return self.shell.exec(self._format_command(command, **params)) diff --git a/src/neofs_testlib/cli/neofs_adm/__init__.py b/src/neofs_testlib/cli/neofs_adm/__init__.py new file mode 100644 index 00000000..dd912200 --- /dev/null +++ b/src/neofs_testlib/cli/neofs_adm/__init__.py @@ -0,0 +1 @@ +from neofs_testlib.cli.neofs_adm.adm import NeofsAdm diff --git a/cli/adm/adm.py b/src/neofs_testlib/cli/neofs_adm/adm.py similarity index 68% rename from cli/adm/adm.py rename to src/neofs_testlib/cli/neofs_adm/adm.py index 0313b78f..4fff981b 100644 --- a/cli/adm/adm.py +++ b/src/neofs_testlib/cli/neofs_adm/adm.py @@ -1,16 +1,14 @@ from typing import Optional -from shell import Shell - -from .config import NeofsAdmConfig -from .morph import NeofsAdmMorph -from .subnet import NeofsAdmMorphSubnet -from .storage_config import NeofsAdmStorageConfig -from .version import NeofsAdmVersion +from neofs_testlib.cli.neofs_adm.config import NeofsAdmConfig +from neofs_testlib.cli.neofs_adm.morph import NeofsAdmMorph +from neofs_testlib.cli.neofs_adm.storage_config import NeofsAdmStorageConfig +from neofs_testlib.cli.neofs_adm.subnet import NeofsAdmMorphSubnet +from neofs_testlib.cli.neofs_adm.version import NeofsAdmVersion +from neofs_testlib.shell import Shell class NeofsAdm: - config: Optional[NeofsAdmConfig] = None morph: Optional[NeofsAdmMorph] = None subnet: Optional[NeofsAdmMorphSubnet] = None storage_config: Optional[NeofsAdmStorageConfig] = None diff --git a/cli/adm/config.py b/src/neofs_testlib/cli/neofs_adm/config.py similarity index 77% rename from cli/adm/config.py rename to src/neofs_testlib/cli/neofs_adm/config.py index 7c21bd58..f8acfd8d 100644 --- a/cli/adm/config.py +++ b/src/neofs_testlib/cli/neofs_adm/config.py @@ -1,8 +1,8 @@ -from cli.cli_command import NeofsCliCommand -from shell import CommandResult +from neofs_testlib.cli.cli_command import CliCommand +from neofs_testlib.shell import CommandResult -class NeofsAdmConfig(NeofsCliCommand): +class NeofsAdmConfig(CliCommand): def init(self, path: str = "~/.neofs/adm/config.yml") -> CommandResult: """Initialize basic neofs-adm configuration file. @@ -20,5 +20,5 @@ class NeofsAdmConfig(NeofsCliCommand): param: param_value for param, param_value in locals().items() if param not in ["self"] - } + }, ) diff --git a/cli/adm/morph.py b/src/neofs_testlib/cli/neofs_adm/morph.py similarity index 95% rename from cli/adm/morph.py rename to src/neofs_testlib/cli/neofs_adm/morph.py index 4fa2c9b0..93c545ba 100644 --- a/cli/adm/morph.py +++ b/src/neofs_testlib/cli/neofs_adm/morph.py @@ -1,10 +1,10 @@ from typing import Optional -from cli.cli_command import NeofsCliCommand -from shell import CommandResult +from neofs_testlib.cli.cli_command import CliCommand +from neofs_testlib.shell import CommandResult -class NeofsAdmMorph(NeofsCliCommand): +class NeofsAdmMorph(CliCommand): def deposit_notary( self, rpc_endpoint: str, @@ -92,7 +92,7 @@ class NeofsAdmMorph(NeofsCliCommand): rpc_endpoint: str, cid: Optional[str] = None, container_contract: Optional[str] = None, - dump: str = './testlib_dump_container', + dump: str = "./testlib_dump_container", ) -> CommandResult: """Dump NeoFS containers to file. @@ -160,7 +160,12 @@ class NeofsAdmMorph(NeofsCliCommand): }, ) - def generate_alphabet(self, rpc_endpoint: str, alphabet_wallets: str, size: int = 7) -> CommandResult: + def generate_alphabet( + self, + rpc_endpoint: str, + alphabet_wallets: str, + size: int = 7, + ) -> CommandResult: """Generate alphabet wallets for consensus nodes of the morph network Args: @@ -284,7 +289,11 @@ class NeofsAdmMorph(NeofsCliCommand): ) def restore_containers( - self, rpc_endpoint: str, alphabet_wallets: str, cid: str, dump: str + self, + rpc_endpoint: str, + alphabet_wallets: str, + cid: str, + dump: str, ) -> CommandResult: """Restore NeoFS containers from file. @@ -347,7 +356,10 @@ class NeofsAdmMorph(NeofsCliCommand): ) def update_contracts( - self, rpc_endpoint: str, alphabet_wallets: str, contracts: Optional[str] = None + self, + rpc_endpoint: str, + alphabet_wallets: str, + contracts: Optional[str] = None, ) -> CommandResult: """Update NeoFS contracts. diff --git a/cli/adm/storage_config.py b/src/neofs_testlib/cli/neofs_adm/storage_config.py similarity index 76% rename from cli/adm/storage_config.py rename to src/neofs_testlib/cli/neofs_adm/storage_config.py index 031bd0f1..aa48f6db 100644 --- a/cli/adm/storage_config.py +++ b/src/neofs_testlib/cli/neofs_adm/storage_config.py @@ -1,8 +1,8 @@ -from cli.cli_command import NeofsCliCommand -from shell import CommandResult +from neofs_testlib.cli.cli_command import CliCommand +from neofs_testlib.shell import CommandResult -class NeofsAdmStorageConfig(NeofsCliCommand): +class NeofsAdmStorageConfig(CliCommand): def set(self, account: str, wallet: str) -> CommandResult: """Initialize basic neofs-adm configuration file. @@ -21,5 +21,5 @@ class NeofsAdmStorageConfig(NeofsCliCommand): param: param_value for param, param_value in locals().items() if param not in ["self"] - } + }, ) diff --git a/cli/adm/subnet.py b/src/neofs_testlib/cli/neofs_adm/subnet.py similarity index 94% rename from cli/adm/subnet.py rename to src/neofs_testlib/cli/neofs_adm/subnet.py index e19c4686..47a1757a 100644 --- a/cli/adm/subnet.py +++ b/src/neofs_testlib/cli/neofs_adm/subnet.py @@ -1,11 +1,13 @@ from typing import Optional -from cli.cli_command import NeofsCliCommand -from shell import CommandResult +from neofs_testlib.cli.cli_command import CliCommand +from neofs_testlib.shell import CommandResult -class NeofsAdmMorphSubnet(NeofsCliCommand): - def create(self, rpc_endpoint: str, address: str, wallet: str, notary: bool = False) -> CommandResult: +class NeofsAdmMorphSubnet(CliCommand): + def create( + self, rpc_endpoint: str, address: str, wallet: str, notary: bool = False + ) -> CommandResult: """Create NeoFS subnet. Args: @@ -25,7 +27,7 @@ class NeofsAdmMorphSubnet(NeofsCliCommand): param: param_value for param, param_value in locals().items() if param not in ["self"] - } + }, ) def get(self, rpc_endpoint: str, subnet: str) -> CommandResult: @@ -46,7 +48,7 @@ class NeofsAdmMorphSubnet(NeofsCliCommand): param: param_value for param, param_value in locals().items() if param not in ["self"] - } + }, ) def remove( @@ -71,7 +73,7 @@ class NeofsAdmMorphSubnet(NeofsCliCommand): param: param_value for param, param_value in locals().items() if param not in ["self"] - } + }, ) def admin_add( @@ -106,7 +108,7 @@ class NeofsAdmMorphSubnet(NeofsCliCommand): param: param_value for param, param_value in locals().items() if param not in ["self"] - } + }, ) def admin_remove( @@ -139,7 +141,7 @@ class NeofsAdmMorphSubnet(NeofsCliCommand): param: param_value for param, param_value in locals().items() if param not in ["self"] - } + }, ) def client_add( @@ -172,7 +174,7 @@ class NeofsAdmMorphSubnet(NeofsCliCommand): param: param_value for param, param_value in locals().items() if param not in ["self"] - } + }, ) def client_remove( @@ -205,7 +207,7 @@ class NeofsAdmMorphSubnet(NeofsCliCommand): param: param_value for param, param_value in locals().items() if param not in ["self"] - } + }, ) def node_add(self, rpc_endpoint: str, wallet: str, node: str, subnet: str) -> CommandResult: @@ -228,7 +230,7 @@ class NeofsAdmMorphSubnet(NeofsCliCommand): param: param_value for param, param_value in locals().items() if param not in ["self"] - } + }, ) def node_remove(self, rpc_endpoint: str, wallet: str, node: str, subnet: str) -> CommandResult: @@ -251,5 +253,5 @@ class NeofsAdmMorphSubnet(NeofsCliCommand): param: param_value for param, param_value in locals().items() if param not in ["self"] - } + }, ) diff --git a/cli/authmate/version.py b/src/neofs_testlib/cli/neofs_adm/version.py similarity index 57% rename from cli/authmate/version.py rename to src/neofs_testlib/cli/neofs_adm/version.py index 4432b2df..8d7c02de 100644 --- a/cli/authmate/version.py +++ b/src/neofs_testlib/cli/neofs_adm/version.py @@ -1,8 +1,8 @@ -from cli.cli_command import NeofsCliCommand -from shell import CommandResult +from neofs_testlib.cli.cli_command import CliCommand +from neofs_testlib.shell import CommandResult -class NeofsAuthmateVersion(NeofsCliCommand): +class NeofsAdmVersion(CliCommand): def get(self) -> CommandResult: """Application version diff --git a/src/neofs_testlib/cli/neofs_authmate/__init__.py b/src/neofs_testlib/cli/neofs_authmate/__init__.py new file mode 100644 index 00000000..5d43b3e4 --- /dev/null +++ b/src/neofs_testlib/cli/neofs_authmate/__init__.py @@ -0,0 +1 @@ +from neofs_testlib.cli.neofs_authmate.authmate import NeofsAuthmate diff --git a/cli/authmate/authmate.py b/src/neofs_testlib/cli/neofs_authmate/authmate.py similarity index 54% rename from cli/authmate/authmate.py rename to src/neofs_testlib/cli/neofs_authmate/authmate.py index 58ee8732..5f86a74e 100644 --- a/cli/authmate/authmate.py +++ b/src/neofs_testlib/cli/neofs_authmate/authmate.py @@ -1,20 +1,14 @@ from typing import Optional -from shell import Shell - -from .secret import NeofsAuthmateSecret -from .version import NeofsAuthmateVersion +from neofs_testlib.cli.neofs_authmate.secret import NeofsAuthmateSecret +from neofs_testlib.cli.neofs_authmate.version import NeofsAuthmateVersion +from neofs_testlib.shell import Shell class NeofsAuthmate: secret: Optional[NeofsAuthmateSecret] = None version: Optional[NeofsAuthmateVersion] = None - def __init__( - self, - shell: Shell, - neofs_authmate_exec_path: str, - ): - + def __init__(self, shell: Shell, neofs_authmate_exec_path: str): self.secret = NeofsAuthmateSecret(shell, neofs_authmate_exec_path) self.version = NeofsAuthmateVersion(shell, neofs_authmate_exec_path) diff --git a/cli/authmate/secret.py b/src/neofs_testlib/cli/neofs_authmate/secret.py similarity index 90% rename from cli/authmate/secret.py rename to src/neofs_testlib/cli/neofs_authmate/secret.py index 66d7e813..12871c8d 100644 --- a/cli/authmate/secret.py +++ b/src/neofs_testlib/cli/neofs_authmate/secret.py @@ -1,18 +1,18 @@ from typing import Optional -from cli.cli_command import NeofsCliCommand -from shell import CommandResult +from neofs_testlib.cli.cli_command import CliCommand +from neofs_testlib.shell import CommandResult -class NeofsAuthmateSecret(NeofsCliCommand): +class NeofsAuthmateSecret(CliCommand): def obtain( - self, - wallet: str, - peer: str, - gate_wallet: str, - access_key_id: str, - address: Optional[str] = None, - gate_address: Optional[str] = None, + self, + wallet: str, + peer: str, + gate_wallet: str, + access_key_id: str, + address: Optional[str] = None, + gate_address: Optional[str] = None, ) -> CommandResult: """Obtain a secret from NeoFS network @@ -34,7 +34,7 @@ class NeofsAuthmateSecret(NeofsCliCommand): param: param_value for param, param_value in locals().items() if param not in ["self"] - } + }, ) def issue( @@ -88,5 +88,5 @@ class NeofsAuthmateSecret(NeofsCliCommand): param: param_value for param, param_value in locals().items() if param not in ["self"] - } + }, ) diff --git a/cli/adm/version.py b/src/neofs_testlib/cli/neofs_authmate/version.py similarity index 56% rename from cli/adm/version.py rename to src/neofs_testlib/cli/neofs_authmate/version.py index 6a2aedda..e146f522 100644 --- a/cli/adm/version.py +++ b/src/neofs_testlib/cli/neofs_authmate/version.py @@ -1,8 +1,8 @@ -from cli.cli_command import NeofsCliCommand -from shell import CommandResult +from neofs_testlib.cli.cli_command import CliCommand +from neofs_testlib.shell import CommandResult -class NeofsAdmVersion(NeofsCliCommand): +class NeofsAuthmateVersion(CliCommand): def get(self) -> CommandResult: """Application version diff --git a/src/neofs_testlib/cli/neogo/__init__.py b/src/neofs_testlib/cli/neogo/__init__.py new file mode 100644 index 00000000..585be9ea --- /dev/null +++ b/src/neofs_testlib/cli/neogo/__init__.py @@ -0,0 +1,2 @@ +from neofs_testlib.cli.neogo.go import NeoGo +from neofs_testlib.cli.neogo.network_type import NetworkType diff --git a/cli/go/candidate.py b/src/neofs_testlib/cli/neogo/candidate.py similarity index 84% rename from cli/go/candidate.py rename to src/neofs_testlib/cli/neogo/candidate.py index 99a42bff..4e796cc8 100644 --- a/cli/go/candidate.py +++ b/src/neofs_testlib/cli/neogo/candidate.py @@ -1,21 +1,20 @@ from typing import Optional -from cli.cli_command import NeofsCliCommand -from shell import CommandResult +from neofs_testlib.cli.cli_command import CliCommand +from neofs_testlib.shell import CommandResult -class NeoGoCandidate(NeofsCliCommand): - +class NeoGoCandidate(CliCommand): def register( - self, - address: str, - rpc_endpoint: str, - wallet: Optional[str] = None, - wallet_config: Optional[str] = None, - gas: Optional[float] = None, - timeout: int = 10, + self, + address: str, + rpc_endpoint: str, + wallet: Optional[str] = None, + wallet_config: Optional[str] = None, + gas: Optional[float] = None, + timeout: int = 10, ) -> CommandResult: - """ register as a new candidate + """Register as a new candidate Args: address (str): Address to register @@ -40,7 +39,7 @@ class NeoGoCandidate(NeofsCliCommand): param: param_value for param, param_value in locals().items() if param not in ["self"] - } + }, ) def unregister( @@ -52,7 +51,7 @@ class NeoGoCandidate(NeofsCliCommand): gas: Optional[float] = None, timeout: int = 10, ) -> CommandResult: - """ unregister self as a candidate + """Unregister self as a candidate Args: address (str): Address to unregister @@ -77,7 +76,7 @@ class NeoGoCandidate(NeofsCliCommand): param: param_value for param, param_value in locals().items() if param not in ["self"] - } + }, ) def vote( @@ -89,8 +88,8 @@ class NeoGoCandidate(NeofsCliCommand): gas: Optional[float] = None, timeout: int = 10, ) -> CommandResult: - """ Votes for a validator by calling "vote" method of a NEO native - contract. Do not provide candidate argument to perform unvoting. + """Votes for a validator by calling "vote" method of a NEO native + contract. Do not provide candidate argument to perform unvoting. Args: @@ -103,7 +102,6 @@ class NeoGoCandidate(NeofsCliCommand): rpc_endpoint (str): RPC node address timeout (int): Timeout for the operation (default: 10s) - Returns: str: Command string @@ -116,5 +114,5 @@ class NeoGoCandidate(NeofsCliCommand): param: param_value for param, param_value in locals().items() if param not in ["self"] - } + }, ) diff --git a/cli/go/contract.py b/src/neofs_testlib/cli/neogo/contract.py similarity index 95% rename from cli/go/contract.py rename to src/neofs_testlib/cli/neogo/contract.py index 5797e06e..a097e4de 100644 --- a/cli/go/contract.py +++ b/src/neofs_testlib/cli/neogo/contract.py @@ -1,10 +1,10 @@ from typing import Optional -from cli.cli_command import NeofsCliCommand -from shell import CommandResult +from neofs_testlib.cli.cli_command import CliCommand +from neofs_testlib.shell import CommandResult -class NeoGoContract(NeofsCliCommand): +class NeoGoContract(CliCommand): def compile( self, input_file: str, @@ -16,7 +16,7 @@ class NeoGoContract(NeofsCliCommand): no_permissions: bool = False, bindings: Optional[str] = None, ) -> CommandResult: - """compile a smart contract to a .nef file + """Compile a smart contract to a .nef file Args: input_file (str): Input file for the smart contract to be compiled @@ -55,9 +55,8 @@ class NeoGoContract(NeofsCliCommand): out: Optional[str] = None, force: bool = False, timeout: int = 10, - ) -> CommandResult: - """deploy a smart contract (.nef with description) + """Deploy a smart contract (.nef with description) Args: wallet (str): wallet to use to get the key for transaction signing; @@ -97,7 +96,7 @@ class NeoGoContract(NeofsCliCommand): config: Optional[str] = None, manifest: Optional[str] = None, ) -> CommandResult: - """generate wrapper to use in other contracts + """Generate wrapper to use in other contracts Args: config (str): Configuration file to use @@ -253,7 +252,7 @@ class NeoGoContract(NeofsCliCommand): name: str, skip_details: bool = False, ) -> CommandResult: - """initialize a new smart-contract in a directory with boiler plate code + """Initialize a new smart-contract in a directory with boiler plate code Args: name (str): name of the smart-contract to be initialized @@ -277,7 +276,7 @@ class NeoGoContract(NeofsCliCommand): input_file: Optional[str] = None, compile: Optional[str] = None, ) -> CommandResult: - """creates a user readable dump of the program instructions + """Creates a user readable dump of the program instructions Args: input_file (str): input file of the program (either .go or .nef) @@ -302,7 +301,7 @@ class NeoGoContract(NeofsCliCommand): manifest: str, sender: Optional[str] = None, ) -> CommandResult: - """calculates hash of a contract after deployment + """Calculates hash of a contract after deployment Args: input_file (str): path to NEF file @@ -331,7 +330,7 @@ class NeoGoContract(NeofsCliCommand): sender: Optional[str] = None, nef: Optional[str] = None, ) -> CommandResult: - """adds group to the manifest + """Adds group to the manifest Args: wallet (str): wallet to use to get the key for transaction signing; diff --git a/cli/go/db.py b/src/neofs_testlib/cli/neogo/db.py similarity index 69% rename from cli/go/db.py rename to src/neofs_testlib/cli/neogo/db.py index 1faf28b0..05bece26 100644 --- a/cli/go/db.py +++ b/src/neofs_testlib/cli/neogo/db.py @@ -1,21 +1,20 @@ from typing import Optional -from cli.cli_command import NeofsCliCommand -from shell import CommandResult - -from .blockchain_network_type import NetworkType +from neofs_testlib.cli.cli_command import CliCommand +from neofs_testlib.cli.neogo.network_type import NetworkType +from neofs_testlib.shell import CommandResult -class NeoGoDb(NeofsCliCommand): +class NeoGoDb(CliCommand): def dump( - self, - config_path: str, - out: str, - network: NetworkType = NetworkType.PRIVATE, - count: int = 0, - start: int = 0, + self, + config_path: str, + out: str, + network: NetworkType = NetworkType.PRIVATE, + count: int = 0, + start: int = 0, ) -> CommandResult: - """ dump blocks (starting with block #1) to the file + """Dump blocks (starting with block #1) to the file Args: config_path (str): path to config @@ -36,19 +35,19 @@ class NeoGoDb(NeofsCliCommand): param: param_value for param, param_value in locals().items() if param not in ["self"] - } + }, ) def restore( - self, - config_path: str, - input_file: str, - network: NetworkType = NetworkType.PRIVATE, - count: int = 0, - dump: Optional[str] = None, - incremental: bool = False, + self, + config_path: str, + input_file: str, + network: NetworkType = NetworkType.PRIVATE, + count: int = 0, + dump: Optional[str] = None, + incremental: bool = False, ) -> CommandResult: - """ dump blocks (starting with block #1) to the file + """Dump blocks (starting with block #1) to the file Args: config_path (str): path to config @@ -70,5 +69,5 @@ class NeoGoDb(NeofsCliCommand): param: param_value for param, param_value in locals().items() if param not in ["self"] - } + }, ) diff --git a/cli/go/go.py b/src/neofs_testlib/cli/neogo/go.py similarity index 60% rename from cli/go/go.py rename to src/neofs_testlib/cli/neogo/go.py index 635d42e7..02aac736 100644 --- a/cli/go/go.py +++ b/src/neofs_testlib/cli/neogo/go.py @@ -1,20 +1,17 @@ from typing import Optional -from shell import Shell - -from .candidate import NeoGoCandidate -from .contract import NeoGoContract -from .db import NeoGoDb -from .nep17 import NeoGoNep17 -from .node import NeoGoNode -from .query import NeoGoQuery -from .version import NeoGoVersion -from .wallet import NeoGoWallet +from neofs_testlib.cli.neogo.candidate import NeoGoCandidate +from neofs_testlib.cli.neogo.contract import NeoGoContract +from neofs_testlib.cli.neogo.db import NeoGoDb +from neofs_testlib.cli.neogo.nep17 import NeoGoNep17 +from neofs_testlib.cli.neogo.node import NeoGoNode +from neofs_testlib.cli.neogo.query import NeoGoQuery +from neofs_testlib.cli.neogo.version import NeoGoVersion +from neofs_testlib.cli.neogo.wallet import NeoGoWallet +from neofs_testlib.shell import Shell class NeoGo: - neo_go_exec_path: Optional[str] = None - config_path: Optional[str] = None candidate: Optional[NeoGoCandidate] = None contract: Optional[NeoGoContract] = None db: Optional[NeoGoDb] = None @@ -30,12 +27,8 @@ class NeoGo: neo_go_exec_path: Optional[str] = None, config_path: Optional[str] = None, ): - self.candidate = NeoGoCandidate( - shell, neo_go_exec_path, config_path=config_path - ) - self.contract = NeoGoContract( - self.neo_go_exec_path, config_path=config_path - ) + self.candidate = NeoGoCandidate(shell, neo_go_exec_path, config_path=config_path) + self.contract = NeoGoContract(shell, neo_go_exec_path, config_path=config_path) self.db = NeoGoDb(shell, neo_go_exec_path, config_path=config_path) self.nep17 = NeoGoNep17(shell, neo_go_exec_path, config_path=config_path) self.node = NeoGoNode(shell, neo_go_exec_path, config_path=config_path) diff --git a/cli/go/nep17.py b/src/neofs_testlib/cli/neogo/nep17.py similarity index 96% rename from cli/go/nep17.py rename to src/neofs_testlib/cli/neogo/nep17.py index 62c936d9..8d89c25a 100644 --- a/cli/go/nep17.py +++ b/src/neofs_testlib/cli/neogo/nep17.py @@ -1,10 +1,10 @@ -from typing import List, Optional +from typing import Optional -from cli.cli_command import NeofsCliCommand -from shell import CommandResult +from neofs_testlib.cli.cli_command import CliCommand +from neofs_testlib.shell import CommandResult -class NeoGoNep17(NeofsCliCommand): +class NeoGoNep17(CliCommand): def balance( self, address: str, @@ -38,7 +38,7 @@ class NeoGoNep17(NeofsCliCommand): param: param_value for param, param_value in locals().items() if param not in ["self"] - } + }, ) def import_token( @@ -74,7 +74,7 @@ class NeoGoNep17(NeofsCliCommand): param: param_value for param, param_value in locals().items() if param not in ["self"] - } + }, ) def info( @@ -104,7 +104,7 @@ class NeoGoNep17(NeofsCliCommand): param: param_value for param, param_value in locals().items() if param not in ["self"] - } + }, ) def remove( @@ -134,7 +134,7 @@ class NeoGoNep17(NeofsCliCommand): param: param_value for param, param_value in locals().items() if param not in ["self"] - } + }, ) def transfer( @@ -188,13 +188,13 @@ class NeoGoNep17(NeofsCliCommand): param: param_value for param, param_value in locals().items() if param not in ["self"] - } + }, ) def multitransfer( self, token: str, - to_address: List[str], + to_address: list[str], sysgas: float, rpc_endpoint: str, wallet: Optional[str] = None, @@ -204,7 +204,6 @@ class NeoGoNep17(NeofsCliCommand): force: bool = False, gas: Optional[float] = None, amount: float = 0, - timeout: int = 10, ) -> CommandResult: """transfer NEP-17 tokens to multiple recipients @@ -239,5 +238,5 @@ class NeoGoNep17(NeofsCliCommand): param: param_value for param, param_value in locals().items() if param not in ["self"] - } + }, ) diff --git a/cli/go/blockchain_network_type.py b/src/neofs_testlib/cli/neogo/network_type.py similarity index 100% rename from cli/go/blockchain_network_type.py rename to src/neofs_testlib/cli/neogo/network_type.py diff --git a/cli/go/node.py b/src/neofs_testlib/cli/neogo/node.py similarity index 63% rename from cli/go/node.py rename to src/neofs_testlib/cli/neogo/node.py index 363dc9b3..0d79561d 100644 --- a/cli/go/node.py +++ b/src/neofs_testlib/cli/neogo/node.py @@ -1,10 +1,9 @@ -from cli.cli_command import NeofsCliCommand -from shell import CommandResult - -from .blockchain_network_type import NetworkType +from neofs_testlib.cli.cli_command import CliCommand +from neofs_testlib.cli.neogo.network_type import NetworkType +from neofs_testlib.shell import CommandResult -class NeoGoNode(NeofsCliCommand): +class NeoGoNode(CliCommand): def start(self, network: NetworkType = NetworkType.PRIVATE) -> CommandResult: """Start a NEO node diff --git a/cli/go/query.py b/src/neofs_testlib/cli/neogo/query.py similarity index 95% rename from cli/go/query.py rename to src/neofs_testlib/cli/neogo/query.py index bdcff77a..1567026c 100644 --- a/cli/go/query.py +++ b/src/neofs_testlib/cli/neogo/query.py @@ -1,10 +1,8 @@ -from typing import Optional - -from cli.cli_command import NeofsCliCommand -from shell import CommandResult +from neofs_testlib.cli.cli_command import CliCommand +from neofs_testlib.shell import CommandResult -class NeoGoQuery(NeofsCliCommand): +class NeoGoQuery(CliCommand): def candidates( self, rpc_endpoint: str, diff --git a/cli/go/version.py b/src/neofs_testlib/cli/neogo/version.py similarity index 57% rename from cli/go/version.py rename to src/neofs_testlib/cli/neogo/version.py index beb3cfa2..18f52bd4 100644 --- a/cli/go/version.py +++ b/src/neofs_testlib/cli/neogo/version.py @@ -1,8 +1,8 @@ -from cli.cli_command import NeofsCliCommand -from shell import CommandResult +from neofs_testlib.cli.cli_command import CliCommand +from neofs_testlib.shell import CommandResult -class NeoGoVersion(NeofsCliCommand): +class NeoGoVersion(CliCommand): def get(self) -> CommandResult: """Application version diff --git a/cli/go/wallet.py b/src/neofs_testlib/cli/neogo/wallet.py similarity index 97% rename from cli/go/wallet.py rename to src/neofs_testlib/cli/neogo/wallet.py index 3d20c258..c5cf0121 100644 --- a/cli/go/wallet.py +++ b/src/neofs_testlib/cli/neogo/wallet.py @@ -1,10 +1,10 @@ from typing import Optional -from cli.cli_command import NeofsCliCommand -from shell import CommandResult +from neofs_testlib.cli.cli_command import CliCommand +from neofs_testlib.shell import CommandResult -class NeoGoWallet(NeofsCliCommand): +class NeoGoWallet(CliCommand): def claim( self, address: str, @@ -36,7 +36,7 @@ class NeoGoWallet(NeofsCliCommand): param: param_value for param, param_value in locals().items() if param not in ["self"] - } + }, ) def init( @@ -66,7 +66,7 @@ class NeoGoWallet(NeofsCliCommand): param: param_value for param, param_value in locals().items() if param not in ["self"] - } + }, ) def convert( @@ -96,7 +96,7 @@ class NeoGoWallet(NeofsCliCommand): param: param_value for param, param_value in locals().items() if param not in ["self"] - } + }, ) def create( @@ -124,7 +124,7 @@ class NeoGoWallet(NeofsCliCommand): param: param_value for param, param_value in locals().items() if param not in ["self"] - } + }, ) def dump( @@ -154,7 +154,7 @@ class NeoGoWallet(NeofsCliCommand): param: param_value for param, param_value in locals().items() if param not in ["self"] - } + }, ) def dump_keys( @@ -184,7 +184,7 @@ class NeoGoWallet(NeofsCliCommand): param: param_value for param, param_value in locals().items() if param not in ["self"] - } + }, ) def export( @@ -214,7 +214,7 @@ class NeoGoWallet(NeofsCliCommand): param: param_value for param, param_value in locals().items() if param not in ["self"] - } + }, ) def import_wif( @@ -248,7 +248,7 @@ class NeoGoWallet(NeofsCliCommand): param: param_value for param, param_value in locals().items() if param not in ["self"] - } + }, ) def import_multisig( @@ -282,7 +282,7 @@ class NeoGoWallet(NeofsCliCommand): param: param_value for param, param_value in locals().items() if param not in ["self"] - } + }, ) def import_deployed( @@ -293,7 +293,6 @@ class NeoGoWallet(NeofsCliCommand): wallet: Optional[str] = None, wallet_config: Optional[str] = None, contract: Optional[str] = None, - timeout: int = 10, ) -> CommandResult: """import multisig contract @@ -321,7 +320,7 @@ class NeoGoWallet(NeofsCliCommand): param: param_value for param, param_value in locals().items() if param not in ["self"] - } + }, ) def remove( @@ -353,7 +352,7 @@ class NeoGoWallet(NeofsCliCommand): param: param_value for param, param_value in locals().items() if param not in ["self"] - } + }, ) def sign( @@ -391,5 +390,5 @@ class NeoGoWallet(NeofsCliCommand): param: param_value for param, param_value in locals().items() if param not in ["self"] - } + }, ) diff --git a/reporter/__init__.py b/src/neofs_testlib/reporter/__init__.py similarity index 64% rename from reporter/__init__.py rename to src/neofs_testlib/reporter/__init__.py index 31bbdf77..5e3c5fcb 100644 --- a/reporter/__init__.py +++ b/src/neofs_testlib/reporter/__init__.py @@ -1,8 +1,8 @@ import os -from reporter.allure_reporter import AllureReporter -from reporter.dummy_reporter import DummyReporter -from reporter.interfaces import Reporter +from neofs_testlib.reporter.allure_reporter import AllureReporter +from neofs_testlib.reporter.dummy_reporter import DummyReporter +from neofs_testlib.reporter.interfaces import Reporter def get_reporter() -> Reporter: diff --git a/reporter/allure_reporter.py b/src/neofs_testlib/reporter/allure_reporter.py similarity index 95% rename from reporter/allure_reporter.py rename to src/neofs_testlib/reporter/allure_reporter.py index 02772146..2d99527a 100644 --- a/reporter/allure_reporter.py +++ b/src/neofs_testlib/reporter/allure_reporter.py @@ -6,7 +6,7 @@ from typing import Any import allure from allure import attachment_type -from reporter.interfaces import Reporter +from neofs_testlib.reporter.interfaces import Reporter class AllureReporter(Reporter): diff --git a/reporter/dummy_reporter.py b/src/neofs_testlib/reporter/dummy_reporter.py similarity index 88% rename from reporter/dummy_reporter.py rename to src/neofs_testlib/reporter/dummy_reporter.py index 90611017..1d8cfde6 100644 --- a/reporter/dummy_reporter.py +++ b/src/neofs_testlib/reporter/dummy_reporter.py @@ -1,7 +1,7 @@ from contextlib import AbstractContextManager, contextmanager from typing import Any -from reporter.interfaces import Reporter +from neofs_testlib.reporter.interfaces import Reporter @contextmanager diff --git a/reporter/interfaces.py b/src/neofs_testlib/reporter/interfaces.py similarity index 100% rename from reporter/interfaces.py rename to src/neofs_testlib/reporter/interfaces.py diff --git a/src/neofs_testlib/shell/__init__.py b/src/neofs_testlib/shell/__init__.py new file mode 100644 index 00000000..c51f3b9e --- /dev/null +++ b/src/neofs_testlib/shell/__init__.py @@ -0,0 +1,3 @@ +from neofs_testlib.shell.interfaces import CommandResult, Shell +from neofs_testlib.shell.local_shell import LocalShell +from neofs_testlib.shell.ssh_shell import SSHShell diff --git a/shell/interfaces.py b/src/neofs_testlib/shell/interfaces.py similarity index 100% rename from shell/interfaces.py rename to src/neofs_testlib/shell/interfaces.py diff --git a/shell/local_shell.py b/src/neofs_testlib/shell/local_shell.py similarity index 98% rename from shell/local_shell.py rename to src/neofs_testlib/shell/local_shell.py index f542cc4f..0b8681a9 100644 --- a/shell/local_shell.py +++ b/src/neofs_testlib/shell/local_shell.py @@ -6,8 +6,8 @@ from typing import IO, Optional import pexpect -from reporter import get_reporter -from shell.interfaces import CommandOptions, CommandResult, Shell +from neofs_testlib.reporter import get_reporter +from neofs_testlib.shell.interfaces import CommandOptions, CommandResult, Shell logger = logging.getLogger("neofs.testlib.shell") reporter = get_reporter() diff --git a/shell/ssh_shell.py b/src/neofs_testlib/shell/ssh_shell.py similarity index 98% rename from shell/ssh_shell.py rename to src/neofs_testlib/shell/ssh_shell.py index 5a272a3c..6ed4f7af 100644 --- a/shell/ssh_shell.py +++ b/src/neofs_testlib/shell/ssh_shell.py @@ -18,8 +18,8 @@ from paramiko import ( ) from paramiko.ssh_exception import AuthenticationException -from reporter import get_reporter -from shell.interfaces import CommandOptions, CommandResult, Shell +from neofs_testlib.reporter import get_reporter +from neofs_testlib.shell.interfaces import CommandOptions, CommandResult, Shell logger = logging.getLogger("neofs.testlib.shell") reporter = get_reporter() diff --git a/tests/helpers.py b/tests/helpers.py index b80be613..1cb393a1 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -1,6 +1,6 @@ import traceback -from shell.interfaces import CommandResult +from neofs_testlib.shell.interfaces import CommandResult def format_error_details(error: Exception) -> str: diff --git a/tests/test_local_shell.py b/tests/test_local_shell.py index 52e3861e..f9c2d892 100644 --- a/tests/test_local_shell.py +++ b/tests/test_local_shell.py @@ -1,7 +1,8 @@ from unittest import TestCase -from shell.interfaces import CommandOptions, InteractiveInput -from shell.local_shell import LocalShell +from neofs_testlib.shell.interfaces import CommandOptions, InteractiveInput +from neofs_testlib.shell.local_shell import LocalShell + from tests.helpers import format_error_details, get_output_lines diff --git a/tests/test_ssh_shell.py b/tests/test_ssh_shell.py index 213b7cf5..849a2fd6 100644 --- a/tests/test_ssh_shell.py +++ b/tests/test_ssh_shell.py @@ -1,8 +1,9 @@ import os from unittest import SkipTest, TestCase -from shell.interfaces import CommandOptions, InteractiveInput -from shell.ssh_shell import SSHShell +from neofs_testlib.shell.interfaces import CommandOptions, InteractiveInput +from neofs_testlib.shell.ssh_shell import SSHShell + from tests.helpers import format_error_details, get_output_lines