diff --git a/README.md b/README.md index e493042..995c946 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 112c15b..0000000 --- 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 1596cb3..0000000 --- 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 112b6a9..0000000 --- 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 d3fa193..0000000 --- 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 b867f00..0000000 --- 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 0000000..27ffbc2 --- /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 a622324..13268f2 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 0000000..dd91220 --- /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 0313b78..4fff981 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 7c21bd5..f8acfd8 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 4fa2c9b..93c545b 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 031bd0f..aa48f6d 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 e19c468..47a1757 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 4432b2d..8d7c02d 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 0000000..5d43b3e --- /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 58ee873..5f86a74 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 66d7e81..12871c8 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 6a2aedd..e146f52 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 0000000..585be9e --- /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 99a42bf..4e796cc 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 5797e06..a097e4d 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 1faf28b..05bece2 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 635d42e..02aac73 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 62c936d..8d89c25 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 363dc9b..0d79561 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 bdcff77..1567026 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 beb3cfa..18f52bd 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 3d20c25..c5cf012 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 31bbdf7..5e3c5fc 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 0277214..2d99527 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 9061101..1d8cfde 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 0000000..c51f3b9 --- /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 f542cc4..0b8681a 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 5a272a3..6ed4f7a 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 b80be61..1cb393a 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 52e3861..f9c2d89 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 213b7cf..849a2fd 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