Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor: duplicated functionality for invoking cli commands on BaseAEATestCase #462

Open
Karrenbelt opened this issue Nov 28, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@Karrenbelt
Copy link

There are two different methods for running cli commands on the BaseAEATestCase, we may opt to deprecate one.

@classmethod
def run_cli_command(cls, *args: str, cwd: str = ".", **kwargs: str) -> Result:
"""
Run AEA CLI command.
:param args: CLI args
:param cwd: the working directory from where to run the command.
:param kwargs: other keyword arguments to click.CliRunner.invoke.
:raises AEATestingException: if command fails.
:return: Result
"""
with cd(cwd):
result = cls.runner.invoke(
cli,
[*CLI_LOG_OPTION, *args],
standalone_mode=False,
catch_exceptions=False,
**kwargs,
)
cls.last_cli_runner_result = result
if result.exit_code != 0: # pragma: nocover
raise AEATestingException(
"Failed to execute AEA CLI command with args {}.\n"
"Exit code: {}\nException: {}\n{}".format(
args, result.exit_code, result.exception, result.output
)
)
return result

@classmethod
def invoke(cls, *args: str) -> Result:
"""Call the cli command."""
with cd(cls._get_cwd()):
result = cls.runner.invoke(
cli, args, standalone_mode=False, catch_exceptions=False
)
return result

@DavidMinarsch DavidMinarsch added the enhancement New feature or request label Dec 23, 2022
@DavidMinarsch
Copy link

Would be good to understand which one is used more and which one we "prefer".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants