Exemple #1
0
 def test__install_dependency_ok(self, *mocks):
     """Test for install_dependency method ok."""
     result = mock.Mock()
     result.returncode = 0
     with mock.patch("aea.helpers.install_dependency.subprocess.Popen",
                     return_value=result):
         install_dependency("test", Dependency("test", "==10.0.0"),
                            mock.Mock())
Exemple #2
0
 def test__install_dependency_fails(self, *mocks):
     """Test for install_dependency method fails."""
     result = mock.Mock()
     result.returncode = 1
     with mock.patch("aea.helpers.install_dependency.subprocess.Popen",
                     return_value=result):
         with self.assertRaises(AEAException):
             install_dependency("test", Dependency("test", "==10.0.0"),
                                mock.Mock())
Exemple #3
0
def do_install(ctx: Context, requirement: Optional[str] = None) -> None:
    """
    Install necessary dependencies.

    :param ctx: context object.
    :param requirement: optional str requirement.

    :return: None
    :raises: ClickException if AEAException occurres.
    """
    try:
        if requirement:
            logger.debug("Installing the dependencies in '{}'...".format(requirement))
            _install_from_requirement(requirement)
        else:
            logger.debug("Installing all the dependencies...")
            dependencies = ctx.get_dependencies()
            for name, d in dependencies.items():
                click.echo(f"Installing {pprint.pformat(name)}...")
                install_dependency(name, d, logger)
    except AEAException as e:
        raise click.ClickException(str(e))