Exemple #1
0
class CreateCommandTestCase(TestCase):
    """Test case for CLI create command."""
    def setUp(self):
        """Set it up."""
        self.runner = CliRunner()

    def test_create_no_init(self):
        """Test for CLI create no init result."""
        result = self.runner.invoke(
            cli,
            [*CLI_LOG_OPTION, "create", "agent_name", "--author=some"],
            standalone_mode=False,
        )
        self.assertEqual(
            result.exception.message,
            "Author is not set up. Please use 'aea init' to initialize.",
        )

    @patch("aea.cli.create.get_or_create_cli_config", return_value={})
    def test_create_no_author_local(self, *mocks):
        """Test for CLI create no author local result."""
        result = self.runner.invoke(
            cli,
            [*CLI_LOG_OPTION, "create", "--local", "agent_name"],
            standalone_mode=False,
        )
        expected_message = (
            "The AEA configurations are not initialized. "
            "Uses `aea init` before continuing or provide optional argument `--author`."
        )
        self.assertEqual(result.exception.message, expected_message)
Exemple #2
0
def test_local_registry_update():
    """Test local-registry-sync cli command."""
    PACKAGES = [
        PackageId(PackageType.CONNECTION, PublicId("fetchai", "local", "0.11.0")),
        PackageId(PackageType.AGENT, PublicId("fetchai", "my_first_aea", "0.10.0")),
    ]
    with TemporaryDirectory() as tmp_dir:
        for package_id in PACKAGES:
            package_dir = os.path.join(
                tmp_dir,
                package_id.public_id.author,
                str(package_id.package_type.to_plural()),
                package_id.public_id.name,
            )
            os.makedirs(package_dir)
            fetch_package(
                str(package_id.package_type),
                public_id=package_id.public_id,
                cwd=tmp_dir,
                dest=package_dir,
            )

        assert set(PACKAGES) == set([i[0] for i in enlist_packages(tmp_dir)])

        runner = CliRunner()
        with cd(tmp_dir):
            # check intention to upgrade
            with patch(
                "aea.cli.local_registry_sync.replace_package"
            ) as replace_package_mock:
                result = runner.invoke(
                    cli, ["-s", "local-registry-sync"], catch_exceptions=False
                )
                assert result.exit_code == 0, result.stdout
            assert replace_package_mock.call_count == len(PACKAGES)

            # do actual upgrade
            result = runner.invoke(
                cli, ["-s", "local-registry-sync"], catch_exceptions=False
            )
            assert result.exit_code == 0, result.stdout

            # check next update will do nothing
            with patch(
                "aea.cli.local_registry_sync.replace_package"
            ) as replace_package_mock:
                result = runner.invoke(
                    cli, ["-s", "local-registry-sync"], catch_exceptions=False
                )
                assert result.exit_code == 0, result.stdout
            assert replace_package_mock.call_count == 0

        def sort_(packages):
            return sorted(packages, key=lambda x: str(x))

        new_packages = [i[0] for i in enlist_packages(tmp_dir)]

        for new_package, old_package in zip(sort_(new_packages), sort_(PACKAGES)):
            assert new_package.public_id > old_package.public_id
Exemple #3
0
def test_mix_std_err_False():
    """Test stderr and stdout not mixed."""
    cli_runner = CliRunner(mix_stderr=False)

    result = cli_runner.invoke(cli, "-v DEBUG run")
    assert result.exit_code == 1
    # check for access, no exception should be raised
    result.stderr
Exemple #4
0
def test_run_ethereum_private_key_config():
    """Test that the command 'aea run' works as expected."""
    runner = CliRunner()
    agent_name = "myagent"
    cwd = os.getcwd()
    t = tempfile.mkdtemp()
    # copy the 'packages' directory in the parent of the agent folder.
    shutil.copytree(Path(ROOT_DIR, "packages"), Path(t, "packages"))

    os.chdir(t)
    result = runner.invoke(
        cli, [*CLI_LOG_OPTION, "init", "--local", "--author", AUTHOR])
    assert result.exit_code == 0

    result = runner.invoke(cli,
                           [*CLI_LOG_OPTION, "create", "--local", agent_name])
    assert result.exit_code == 0

    os.chdir(Path(t, agent_name))

    result = runner.invoke(cli, [
        *CLI_LOG_OPTION, "add", "--local", "connection", "fetchai/local:0.1.0"
    ])
    assert result.exit_code == 0

    # Load the agent yaml file and manually insert the things we need
    file = open("aea-config.yaml", mode="r")

    # read all lines at once
    whole_file = file.read()

    find_text = "private_key_paths: {}"
    replace_text = """private_key_paths:
    ethereum: default_private_key_not.txt"""

    whole_file = whole_file.replace(find_text, replace_text)

    # close the file
    file.close()

    with open("aea-config.yaml", "w") as f:
        f.write(whole_file)

    error_msg = ""
    try:
        cli.main(
            [*CLI_LOG_OPTION, "run", "--connections", "fetchai/local:0.1.0"])
    except SystemExit as e:
        error_msg = str(e)

    assert error_msg == "1"

    os.chdir(cwd)
    try:
        shutil.rmtree(t)
    except (OSError, IOError):
        pass
Exemple #5
0
def test_mix_std_err_True():
    """Test stderr and stdout are mixed."""
    cli_runner = CliRunner(mix_stderr=True)

    result = cli_runner.invoke(cli, "-v DEBUG run")
    assert result.exit_code == 1

    with pytest.raises(ValueError):
        result.stderr
Exemple #6
0
 def setup(self):
     """Set the test up."""
     self.cwd = os.getcwd()
     self.t = tempfile.mkdtemp()
     os.chdir(self.t)
     self.runner = CliRunner()
     self.project_public_id = MY_FIRST_AEA_PUBLIC_ID
     self.project_path = os.path.join(
         self.t, self.project_public_id.author, self.project_public_id.name
     )
Exemple #7
0
def test_invoke():
    """Test runner invoke method."""
    cli_runner = CliRunner()

    result = cli_runner.invoke(cli, ["--help"])
    assert ("Command-line tool for setting up an Autonomous Economic Agent"
            in result.output)

    result = cli_runner.invoke(cli, "--help")
    assert ("Command-line tool for setting up an Autonomous Economic Agent"
            in result.output)
Exemple #8
0
def test_invoke_error():
    """Test runner invoke method raises an error."""
    cli_runner = CliRunner()

    with patch.object(cli, "main", side_effect=SystemExit(1)):
        result = cli_runner.invoke(cli, ["--help"])
        assert result.exit_code == 1

    with patch.object(cli, "main", side_effect=SystemExit(object())):
        result = cli_runner.invoke(cli, ["--help"])
        assert result.exit_code == 1
Exemple #9
0
 def setup(self):
     """Set the test up."""
     self.runner = CliRunner()
     self.agent_name = "myagent"
     self.cwd = os.getcwd()
     self.t = tempfile.mkdtemp()
     self.agent_folder = Path(self.t, self.agent_name)
     os.chdir(self.t)
     self.cli_config_file = f"{self.t}/cli_config.yaml"
     self.cli_config_patch = patch("aea.cli.utils.config.CLI_CONFIG_PATH",
                                   self.cli_config_file)
     self.cli_config_patch.start()
Exemple #10
0
 def setUp(self):
     """Set the test up."""
     self.runner = CliRunner()
     self.schema = json.load(open(AGENT_CONFIGURATION_SCHEMA))
     self.resolver = jsonschema.RefResolver(
         "file://{}/".format(Path(CONFIGURATION_SCHEMA_DIR).absolute()),
         self.schema)
     self.validator = Draft4Validator(self.schema, resolver=self.resolver)
     self.cwd = os.getcwd()
     self.t = tempfile.mkdtemp()
     # copy the 'dummy_aea' directory in the parent of the agent folder.
     shutil.copytree(Path(CUR_PATH, "data", "dummy_aea"),
                     Path(self.t, "dummy_aea"))
     os.chdir(Path(self.t, "dummy_aea"))
Exemple #11
0
def test_catch_exception():
    """Test runner invoke method raises an exception and its propogated."""
    cli_runner = CliRunner()

    # True
    with patch.object(cli, "main", side_effect=ValueError("expected")):
        result = cli_runner.invoke(cli, ["--help"])
        assert result.exit_code == 1

    # False

    with pytest.raises(ValueError, match="expected"):
        with patch.object(cli, "main", side_effect=ValueError("expected")):
            result = cli_runner.invoke(cli, ["--help"], catch_exceptions=False)
Exemple #12
0
class RegisterTestCase(TestCase):
    """Test case for CLI register command."""
    def setUp(self):
        """Set it up."""
        self.runner = CliRunner()

    def test_register_positive(self, do_register_mock):
        """Test for CLI register positive result."""
        username = "******"
        email = "*****@*****.**"
        fake_pwd = "fake_pwd"  # nosec

        result = self.runner.invoke(
            cli,
            [
                *CLI_LOG_OPTION,
                "register",
                "--username={}".format(username),
                "--email={}".format(email),
                "--password={}".format(fake_pwd),
                "--confirm_password={}".format(fake_pwd),
            ],
            standalone_mode=False,
        )
        self.assertEqual(result.exit_code, 0)
        do_register_mock.assert_called_once_with(username, email, fake_pwd,
                                                 fake_pwd)
Exemple #13
0
    def setup_class(cls) -> None:
        """Set up the test class."""
        cls.method_list = [
            func
            for func in dir(cls)
            if callable(getattr(cls, func))
            and not func.startswith("__")
            and func.startswith("test_")
        ]
        cls.runner = CliRunner()
        cls.old_cwd = Path(os.getcwd())
        cls.subprocesses = []
        cls.threads = []

        cls.t = Path(tempfile.mkdtemp())
        cls.change_directory(cls.t)

        cls.package_registry_src = cls.old_cwd / cls.package_registry_src_rel
        if cls.use_packages_dir:
            registry_tmp_dir = cls.t / cls.packages_dir_path
            shutil.copytree(str(cls.package_registry_src), str(registry_tmp_dir))

        cls.initialize_aea(cls.author)
        cls.stdout = {}
        cls.stderr = {}
Exemple #14
0
    def setup_class(cls):
        """Set the test up."""
        cls.cwd = os.getcwd()
        cls.t = tempfile.mkdtemp()
        os.chdir(cls.t)

        cls.runner = CliRunner()
        cls.agent_name = "myagent"
        result = cls.runner.invoke(
            cli, [*CLI_LOG_OPTION, "init", "--local", "--author", AUTHOR])
        assert result.exit_code == 0

        cls.result = cls.runner.invoke(
            cli,
            [*CLI_LOG_OPTION, "create", "--local", cls.agent_name],
            standalone_mode=False,
        )
        assert cls.result.exit_code == 0

        # calling 'aea create myagent' again within an AEA project - recursively.
        os.chdir(cls.agent_name)
        os.mkdir("another_subdir")
        os.chdir("another_subdir")
        cls.result = cls.runner.invoke(
            cli,
            [*CLI_LOG_OPTION, "create", "--local", cls.agent_name],
            standalone_mode=False,
        )
Exemple #15
0
 def setup_class(cls):
     """Set the test up."""
     cls.runner = CliRunner()
     cls.agent_name = "myagent"
     cls.cwd = os.getcwd()
     cls.t = tempfile.mkdtemp()
     os.chdir(cls.t)
Exemple #16
0
    def setup_class(cls):
        """Set the test up."""
        cls.runner = CliRunner()
        cls.agent_name = "myagent"
        cls.cwd = os.getcwd()
        cls.t = tempfile.mkdtemp()
        # copy the 'packages' directory in the parent of the agent folder.
        shutil.copytree(Path(ROOT_DIR, "packages"), Path(cls.t, "packages"))

        os.chdir(cls.t)
        result = cls.runner.invoke(
            cli, [*CLI_LOG_OPTION, "init", "--local", "--author", AUTHOR])
        assert result.exit_code == 0

        result = cls.runner.invoke(
            cli,
            [*CLI_LOG_OPTION, "create", "--local", cls.agent_name],
            standalone_mode=False,
        )
        assert result.exit_code == 0

        Path(cls.t, cls.agent_name, DEFAULT_AEA_CONFIG_FILE).write_text("")

        os.chdir(Path(cls.t, cls.agent_name))

        cls.result = cls.runner.invoke(cli, [*CLI_LOG_OPTION, "run"],
                                       standalone_mode=False)
Exemple #17
0
    def setup_class(cls):
        """Set the test up."""
        cls.runner = CliRunner()
        cls.agent_name = "myagent"
        cls.connection_id = "author/unknown_connection:0.1.0"
        cls.connection_name = "unknown_connection"
        cls.cwd = os.getcwd()
        cls.t = tempfile.mkdtemp()
        # copy the 'packages' directory in the parent of the agent folder.
        shutil.copytree(Path(ROOT_DIR, "packages"), Path(cls.t, "packages"))

        os.chdir(cls.t)
        result = cls.runner.invoke(
            cli, [*CLI_LOG_OPTION, "init", "--local", "--author", AUTHOR])
        assert result.exit_code == 0

        result = cls.runner.invoke(
            cli,
            [*CLI_LOG_OPTION, "create", "--local", cls.agent_name],
            standalone_mode=False,
        )
        assert result.exit_code == 0

        os.chdir(Path(cls.t, cls.agent_name))

        cls.result = cls.runner.invoke(
            cli,
            [*CLI_LOG_OPTION, "run", "--connections", cls.connection_id],
            standalone_mode=False,
        )
Exemple #18
0
    def setup_class(cls):
        """Set the test up."""
        cls.runner = CliRunner()
        cls.agent_name = "myagent"
        cls.cwd = os.getcwd()
        cls.t = tempfile.mkdtemp()
        cls.connection_id = "fetchai/local:0.1.0"

        os.chdir(cls.t)
        result = cls.runner.invoke(
            cli, [*CLI_LOG_OPTION, "init", "--local", "--author", AUTHOR]
        )
        assert result.exit_code == 0
        result = cls.runner.invoke(
            cli,
            [*CLI_LOG_OPTION, "create", "--local", cls.agent_name],
            standalone_mode=False,
        )
        assert result.exit_code == 0
        os.chdir(cls.agent_name)

        cls.result = cls.runner.invoke(
            cli,
            [*CLI_LOG_OPTION, "remove", "connection", cls.connection_id],
            standalone_mode=False,
        )
Exemple #19
0
class ListContractsCommandTestCase(TestCase):
    """Test that the command 'aea list contracts' works as expected."""
    def setUp(self):
        """Set the test up."""
        self.runner = CliRunner()
        self.schema = json.load(open(AGENT_CONFIGURATION_SCHEMA))
        self.resolver = jsonschema.RefResolver(
            "file://{}/".format(Path(CONFIGURATION_SCHEMA_DIR).absolute()),
            self.schema)
        self.validator = Draft4Validator(self.schema, resolver=self.resolver)
        self.cwd = os.getcwd()
        self.t = tempfile.mkdtemp()
        # copy the 'dummy_aea' directory in the parent of the agent folder.
        shutil.copytree(Path(CUR_PATH, "data", "dummy_aea"),
                        Path(self.t, "dummy_aea"))
        os.chdir(Path(self.t, "dummy_aea"))

    @mock.patch("aea.cli.list._get_item_details")
    @mock.patch("aea.cli.utils.formatting.format_items")
    def test_list_contracts_positive(self, *mocks):
        """Test list contracts command positive result."""
        result = self.runner.invoke(cli,
                                    [*CLI_LOG_OPTION, "list", "contracts"],
                                    standalone_mode=False)
        self.assertEqual(result.exit_code, 0)

    def tearDown(self):
        """Tear the test down."""
        os.chdir(self.cwd)
        try:
            shutil.rmtree(self.t)
        except (OSError, IOError):
            pass
Exemple #20
0
    def setup_class(cls):
        """Set the test up."""
        cls.runner = CliRunner()
        cls.agent_name = "myagent"
        cls.cwd = os.getcwd()
        cls.t = tempfile.mkdtemp()
        cls.protocol_id = "fetchai/gym:0.1.0"
        cls.protocol_name = "gym"

        # copy the 'packages' directory in the parent of the agent folder.
        shutil.copytree(Path(CUR_PATH, "..", "packages"),
                        Path(cls.t, "packages"))

        os.chdir(cls.t)
        result = cls.runner.invoke(
            cli, [*CLI_LOG_OPTION, "init", "--local", "--author", AUTHOR])
        assert result.exit_code == 0

        result = cls.runner.invoke(
            cli,
            [*CLI_LOG_OPTION, "create", "--local", cls.agent_name],
            standalone_mode=False,
        )
        assert result.exit_code == 0

        os.chdir(cls.agent_name)
        Path(cls.t, cls.agent_name, "vendor", "fetchai", "protocols",
             cls.protocol_name).mkdir(parents=True, exist_ok=True)
        cls.result = cls.runner.invoke(
            cli,
            [*CLI_LOG_OPTION, "add", "--local", "protocol", cls.protocol_id],
            standalone_mode=False,
        )
Exemple #21
0
    def setup_class(cls):
        """Set the test up."""
        cls.runner = CliRunner()
        cls.agent_name = "myagent"
        cls.resource_name = "myresource"
        cls.cwd = os.getcwd()
        cls.t = tempfile.mkdtemp()

        cls.schema = json.load(open(PROTOCOL_CONFIGURATION_SCHEMA))
        cls.resolver = jsonschema.RefResolver(
            make_jsonschema_base_uri(
                Path(CONFIGURATION_SCHEMA_DIR).absolute()),
            cls.schema,
        )
        cls.validator = Draft4Validator(cls.schema, resolver=cls.resolver)

        os.chdir(cls.t)
        result = cls.runner.invoke(
            cli, [*CLI_LOG_OPTION, "init", "--local", "--author", AUTHOR])
        assert result.exit_code == 0
        result = cls.runner.invoke(
            cli,
            [*CLI_LOG_OPTION, "create", "--local", cls.agent_name],
            standalone_mode=False,
        )
        assert result.exit_code == 0
        os.chdir(cls.agent_name)
        # scaffold protocol
        cls.result = cls.runner.invoke(
            cli,
            [*CLI_LOG_OPTION, "scaffold", "protocol", cls.resource_name],
            standalone_mode=False,
        )
Exemple #22
0
    def setup_class(cls):
        """Set the test up."""
        cls.runner = CliRunner()
        cls.agent_name = "myagent"
        cls.resource_name = "myresource"
        cls.cwd = os.getcwd()
        cls.t = tempfile.mkdtemp()

        os.chdir(cls.t)
        result = cls.runner.invoke(
            cli, [*CLI_LOG_OPTION, "init", "--local", "--author", AUTHOR])
        assert result.exit_code == 0
        result = cls.runner.invoke(
            cli,
            [*CLI_LOG_OPTION, "create", "--local", cls.agent_name],
            standalone_mode=False,
        )
        assert result.exit_code == 0

        cls.patch = unittest.mock.patch(
            "shutil.copytree", side_effect=Exception("unknwon exception"))
        cls.patch.start()

        os.chdir(cls.agent_name)
        cls.result = cls.runner.invoke(
            cli,
            [*CLI_LOG_OPTION, "scaffold", "protocol", cls.resource_name],
            standalone_mode=False,
        )
Exemple #23
0
    def setup_class(cls):
        """Set the test up."""
        cls.runner = CliRunner()
        cls.agent_name = "myagent"
        cls.resource_name = "myresource"
        cls.cwd = os.getcwd()
        cls.t = tempfile.mkdtemp()

        os.chdir(cls.t)
        result = cls.runner.invoke(
            cli, [*CLI_LOG_OPTION, "init", "--local", "--author", AUTHOR])
        assert result.exit_code == 0
        result = cls.runner.invoke(
            cli,
            [*CLI_LOG_OPTION, "create", "--local", cls.agent_name],
            standalone_mode=False,
        )
        assert result.exit_code == 0
        os.chdir(cls.agent_name)
        # add protocol first time
        result = cls.runner.invoke(
            cli,
            [*CLI_LOG_OPTION, "scaffold", "protocol", cls.resource_name],
            standalone_mode=False,
        )
        assert result.exit_code == 0
        # scaffold protocol with the same protocol name
        cls.result = cls.runner.invoke(
            cli,
            [*CLI_LOG_OPTION, "scaffold", "protocol", cls.resource_name],
            standalone_mode=False,
        )
Exemple #24
0
    def setup_class(cls):
        """Set the test up."""
        cls.runner = CliRunner()
        cls.agent_name = "myagent"
        cls.resource_name = "myresource"
        cls.cwd = os.getcwd()
        cls.t = tempfile.mkdtemp()

        os.chdir(cls.t)
        result = cls.runner.invoke(
            cli, [*CLI_LOG_OPTION, "init", "--local", "--author", AUTHOR])
        assert result.exit_code == 0
        result = cls.runner.invoke(
            cli,
            [*CLI_LOG_OPTION, "create", "--local", cls.agent_name],
            standalone_mode=False,
        )
        assert result.exit_code == 0

        # change the dumping of yaml module to raise an exception.
        cls.patch = unittest.mock.patch(
            "yaml.dump", side_effect=ValidationError("test error message"))
        cls.patch.start()

        os.chdir(cls.agent_name)
        cls.result = cls.runner.invoke(
            cli,
            [*CLI_LOG_OPTION, "scaffold", "protocol", cls.resource_name],
            standalone_mode=False,
        )
Exemple #25
0
    def setup_class(cls):
        """Set the test up."""
        cls.runner = CliRunner()
        cls.agent_name = "myagent"
        cls.resource_name = "myresource"
        cls.cwd = os.getcwd()
        cls.t = tempfile.mkdtemp()

        os.chdir(cls.t)
        result = cls.runner.invoke(
            cli, [*CLI_LOG_OPTION, "init", "--local", "--author", AUTHOR])
        assert result.exit_code == 0
        result = cls.runner.invoke(
            cli,
            [*CLI_LOG_OPTION, "create", "--local", cls.agent_name],
            standalone_mode=False,
        )
        assert result.exit_code == 0
        os.chdir(cls.agent_name)
        # create a dummy 'myresource' folder
        Path(cls.t, cls.agent_name, "protocols",
             cls.resource_name).mkdir(exist_ok=False, parents=True)
        cls.result = cls.runner.invoke(
            cli,
            [*CLI_LOG_OPTION, "scaffold", "protocol", cls.resource_name],
            standalone_mode=False,
        )
Exemple #26
0
    def setup_class(cls):
        """Set the test up."""
        cls.runner = CliRunner()
        cls.agent_name = "myagent"
        cls.cwd = os.getcwd()
        cls.t = tempfile.mkdtemp()
        cls.agent_folder = Path(cls.t, cls.agent_name)
        os.chdir(cls.t)

        result = cls.runner.invoke(
            cli, [*CLI_LOG_OPTION, "init", "--local", "--author", AUTHOR])

        result = cls.runner.invoke(
            cli, [*CLI_LOG_OPTION, "create", "--local", cls.agent_name])
        assert result.exit_code == 0
        os.chdir(Path(cls.t, cls.agent_name))

        shutil.copy(
            Path(CUR_PATH, "data", "fet_private_key.txt"),
            cls.agent_folder / FETCHAI_PRIVATE_KEY_FILE,
        )

        cls.result = cls.runner.invoke(
            cli,
            [
                *CLI_LOG_OPTION,
                "add-key",
                FetchAICrypto.identifier,
                FETCHAI_PRIVATE_KEY_FILE,
            ],
        )
Exemple #27
0
    def setup_class(cls):
        """Set the test up."""
        cls.runner = CliRunner()
        cls.agent_name = "myagent"
        cls.cwd = os.getcwd()
        cls.t = tempfile.mkdtemp()
        cls.skill_name = "error"
        cls.skill_author = "fetchai"
        cls.skill_version = "0.1.0"
        cls.skill_id = cls.skill_author + "/" + cls.skill_name + ":" + cls.skill_version

        # copy the 'packages' directory in the parent of the agent folder.
        shutil.copytree(Path(CUR_PATH, "..", "packages"),
                        Path(cls.t, "packages"))

        os.chdir(cls.t)
        result = cls.runner.invoke(
            cli, [*CLI_LOG_OPTION, "init", "--local", "--author", AUTHOR])
        assert result.exit_code == 0

        result = cls.runner.invoke(
            cli,
            [*CLI_LOG_OPTION, "create", "--local", cls.agent_name],
            standalone_mode=False,
        )
        # this also by default adds the oef skill and error skill
        assert result.exit_code == 0
        os.chdir(cls.agent_name)

        # add the error skill again
        cls.result = cls.runner.invoke(
            cli,
            [*CLI_LOG_OPTION, "add", "--local", "skill", cls.skill_id],
            standalone_mode=False,
        )
Exemple #28
0
    def setup_class(cls):
        """Set the test up."""
        cls.runner = CliRunner()
        cls.agent_name = "myagent"
        cls.cwd = os.getcwd()
        cls.t = tempfile.mkdtemp()
        cls.skill_id = "different_author/error:0.1.0"
        cls.skill_name = "unknown_skill"

        # copy the 'packages' directory in the parent of the agent folder.
        shutil.copytree(Path(CUR_PATH, "..", "packages"),
                        Path(cls.t, "packages"))

        os.chdir(cls.t)
        result = cls.runner.invoke(
            cli, [*CLI_LOG_OPTION, "init", "--local", "--author", AUTHOR])
        assert result.exit_code == 0

        result = cls.runner.invoke(
            cli,
            [*CLI_LOG_OPTION, "create", "--local", cls.agent_name],
            standalone_mode=False,
        )
        assert result.exit_code == 0
        os.chdir(cls.agent_name)
        cls.result = cls.runner.invoke(
            cli,
            [*CLI_LOG_OPTION, "add", "--local", "skill", cls.skill_id],
            standalone_mode=False,
        )
Exemple #29
0
def test_flag_help():
    """Test that the flag '--help' works correctly."""
    runner = CliRunner()
    result = runner.invoke(cli, ["--help"])
    assert (result.stdout == """Usage: aea [OPTIONS] COMMAND [ARGS]...

  Command-line tool for setting up an Autonomous Economic Agent.

Options:
  --version                 Show the version and exit.
  -v, --verbosity LVL       One of NOTSET, DEBUG, INFO, WARNING, ERROR,
                            CRITICAL, OFF

  --skip-consistency-check  Skip consistency check.
  --help                    Show this message and exit.

Commands:
  add              Add a resource to the agent.
  add-key          Add a private key to the wallet.
  config           Read or modify a configuration.
  create           Create an agent.
  delete           Delete an agent.
  fetch            Fetch Agent from Registry.
  fingerprint      Fingerprint a resource.
  freeze           Get the dependencies.
  generate         Generate a resource for the agent.
  generate-key     Generate private keys.
  generate-wealth  Generate wealth for address on test network.
  get-address      Get the address associated with the private key.
  get-wealth       Get the wealth associated with the private key.
  gui              Run the CLI GUI.
  init             Initialize your AEA configurations.
  install          Install the dependencies.
  interact         Interact with a running AEA via the stub connection.
  launch           Launch many agents at the same time.
  list             List the installed resources.
  login            Login to Registry account.
  logout           Logout from Registry account.
  publish          Publish Agent to Registry.
  push             Push item to Registry or save it in local packages.
  register         Register a new Registry account.
  remove           Remove a resource from the agent.
  run              Run the agent.
  scaffold         Scaffold a resource for the agent.
  search           Search for components in the registry.
""")
Exemple #30
0
 def setup_class(cls):
     """Set the test up."""
     cls.cwd = os.getcwd()
     cls.t = tempfile.mkdtemp()
     shutil.copytree(Path(CUR_PATH, "data", "dummy_aea"),
                     Path(cls.t, "dummy_aea"))
     os.chdir(Path(cls.t, "dummy_aea"))
     cls.runner = CliRunner()