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, )
def setup_class(cls): """Set up the test class.""" cls.runner = CliRunner() cls.agent_name = "myagent" # change the serialization of the AgentConfig class so to make the parsing to fail. cls.patch = patch.object( aea.configurations.base.AgentConfig, "json", return_value={"hello": "world"} ) cls.patch.start() 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 cls.result = cls.runner.invoke( cli, [*CLI_LOG_OPTION, "create", "--local", cls.agent_name], standalone_mode=False, )
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(CUR_PATH, "..", "packages"), Path(cls.t, "packages")) cls.protocol_id = str(GymMessage.protocol_id) cls.protocol_name = "gym" 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) result = cls.runner.invoke( cli, [*CLI_LOG_OPTION, "add", "--local", "protocol", cls.protocol_id], standalone_mode=False, ) assert result.exit_code == 0 cls.result = cls.runner.invoke( cli, [*CLI_LOG_OPTION, "remove", "protocol", cls.protocol_id], standalone_mode=False, )
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)
def test_fetch_twice_remote(): """Test fails on fetch if dir exists.""" with TemporaryDirectory() as tmp_dir: with cd(tmp_dir): name = "my_first_aea" runner = CliRunner() result = runner.invoke( cli, [ "--registry-path", PACKAGES_DIR, "fetch", "--local", "fetchai/my_first_aea", ], catch_exceptions=False, ) assert result.exit_code == 0, result.stdout assert os.path.exists(name) with pytest.raises( ClickException, match='Item "my_first_aea" already exists in target folder.', ): result = runner.invoke( cli, ["fetch", "--remote", "fetchai/my_first_aea"], standalone_mode=False, catch_exceptions=False, )
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, )
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, "connections", cls.resource_name).mkdir( exist_ok=False, parents=True ) cls.result = cls.runner.invoke( cli, [*CLI_LOG_OPTION, "scaffold", "connection", cls.resource_name], standalone_mode=False, )
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() dir_path = Path("packages") tmp_dir = cls.t / dir_path src_dir = cls.cwd / Path(ROOT_DIR, dir_path) shutil.copytree(str(src_dir), str(tmp_dir)) 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", "skill", cls.resource_name], standalone_mode=False, )
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()
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.3.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, )
def test_add_key_fails_bad_ledger_id(): """Test that 'aea add-key' fails because the ledger id is not valid.""" oldcwd = os.getcwd() runner = CliRunner() agent_name = "myagent" tmpdir = tempfile.mkdtemp() os.chdir(tmpdir) try: result = runner.invoke( cli, [*CLI_LOG_OPTION, "init", "--local", "--author", AUTHOR]) result = runner.invoke( cli, [*CLI_LOG_OPTION, "create", "--local", agent_name]) assert result.exit_code == 0 os.chdir(Path(tmpdir, agent_name)) # generate a private key file result = runner.invoke(cli, [*CLI_LOG_OPTION, "generate-key", FETCHAI]) assert result.exit_code == 0 assert Path(FETCHAI_PRIVATE_KEY_FILE).exists() bad_ledger_id = "this_is_a_bad_ledger_id" result = runner.invoke(cli, [ *CLI_LOG_OPTION, "add-key", bad_ledger_id, FETCHAI_PRIVATE_KEY_FILE ]) assert result.exit_code == 2 # check that no key has been added. f = open(Path(DEFAULT_AEA_CONFIG_FILE)) expected_json = yaml.safe_load(f) config = AgentConfig.from_json(expected_json) assert len(config.private_key_paths.read_all()) == 0 finally: os.chdir(oldcwd)
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", FETCHAI_PRIVATE_KEY_FILE), cls.agent_folder / FETCHAI_PRIVATE_KEY_FILE, ) shutil.copy( Path(CUR_PATH, "data", ETHEREUM_PRIVATE_KEY_FILE), cls.agent_folder / ETHEREUM_PRIVATE_KEY_FILE, )
def setup_class(cls): """Set the test up.""" cls.cwd = os.getcwd() cls.t = tempfile.mkdtemp() dir_path = Path("packages") tmp_dir = cls.t / dir_path src_dir = cls.cwd / Path(ROOT_DIR, dir_path) shutil.copytree(str(src_dir), str(tmp_dir)) 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, )
def setup_class(cls): """Set up the test class.""" cls.runner = CliRunner() cls.agent_name = "myagent" # change the serialization of the AgentConfig class so to make the parsing to fail. cls.patch = patch.object(ConfigLoader, "dump", side_effect=Exception) cls.patch.start() cls.cwd = os.getcwd() cls.t = tempfile.mkdtemp() dir_path = Path("packages") tmp_dir = cls.t / dir_path src_dir = cls.cwd / Path(ROOT_DIR, dir_path) shutil.copytree(str(src_dir), str(tmp_dir)) os.chdir(cls.t) 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, )
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 connection first time result = cls.runner.invoke( cli, [*CLI_LOG_OPTION, "scaffold", "connection", cls.resource_name], standalone_mode=False, ) assert result.exit_code == 0 # scaffold connection with the same connection name cls.result = cls.runner.invoke( cli, [*CLI_LOG_OPTION, "scaffold", "connection", cls.resource_name], standalone_mode=False, )
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() dir_path = Path("packages") tmp_dir = cls.t / dir_path src_dir = cls.cwd / Path(ROOT_DIR, dir_path) shutil.copytree(str(src_dir), str(tmp_dir)) 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, "skills", cls.resource_name).mkdir(exist_ok=False, parents=True) cls.result = cls.runner.invoke( cli, [*CLI_LOG_OPTION, "scaffold", "skill", cls.resource_name], standalone_mode=False, )
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(CONNECTION_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 connection cls.result = cls.runner.invoke( cli, [*CLI_LOG_OPTION, "scaffold", "connection", cls.resource_name], standalone_mode=False, )
def setup_class(cls): """Set the test up.""" if cls is BaseLaunchTestCase: raise unittest.SkipTest("Skip BaseTest tests, it's a base class") cls.runner = CliRunner() cls.agent_name_1 = "myagent_1" cls.agent_name_2 = "myagent_2" cls.cwd = os.getcwd() cls.t = tempfile.mkdtemp() dir_path = Path("packages") tmp_dir = cls.t / dir_path src_dir = cls.cwd / Path(ROOT_DIR, dir_path) shutil.copytree(str(src_dir), str(tmp_dir)) 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_1] ) assert result.exit_code == 0 result = cls.runner.invoke( cli, [*CLI_LOG_OPTION, "create", "--local", cls.agent_name_2] ) assert result.exit_code == 0
def setup_class(cls): """Set the test up.""" cls.runner = CliRunner() cls.agent_name = "myagent" cls.cwd = os.getcwd() cls.t = tempfile.mkdtemp() dir_path = Path("packages") tmp_dir = cls.t / dir_path src_dir = cls.cwd / Path(ROOT_DIR, dir_path) shutil.copytree(str(src_dir), str(tmp_dir)) 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", FETCHAI_PRIVATE_KEY_FILE), cls.agent_folder / FETCHAI_PRIVATE_KEY_FILE, ) cls.result = cls.runner.invoke( cli, [*CLI_LOG_OPTION, "add-key", FETCHAI, FETCHAI_PRIVATE_KEY_FILE], )
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 = "fetchai/gym:0.4.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", "skill", cls.skill_id], standalone_mode=False, )
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, )
def setup_class(cls): """Set the test up.""" cls.schema = json.load(open(AGENT_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) cls.runner = CliRunner() cls.agent_name = "myagent" cls.cwd = os.getcwd() cls.t = tempfile.mkdtemp() os.chdir(cls.t) cls.cli_config_file = f"{cls.t}/cli_config.yaml" cls.cli_config_patch = patch("aea.cli.utils.config.CLI_CONFIG_PATH", cls.cli_config_file) cls.cli_config_patch.start() 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, ) cls.agent_config = cls._load_config_file(cls.agent_name)
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 = PublicId.from_str("fetchai/error:0.3.0") cls.skill_name = cls.skill_id.name cls.skill_author = cls.skill_id.author cls.skill_version = cls.skill_id.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", str(cls.skill_id)], standalone_mode=False, )
def setup_class(cls): """Set the test up.""" cls.cwd = os.getcwd() cls.runner = CliRunner() cls.t = tempfile.mkdtemp() os.chdir(cls.t) # copy the packages directory in the temporary test directory. shutil.copytree(Path(ROOT_DIR, "packages"), Path(cls.t, "packages")) # remove all the skills except the echo skill (to make testing easier). [ shutil.rmtree(p) for p in Path(cls.t, "packages", "fetchai", "skills").iterdir() if p.name != "echo" and p.is_dir() ] result = cls.runner.invoke( cli, [*CLI_LOG_OPTION, "init", "--local", "--author", AUTHOR]) assert result.exit_code == 0 # create an AEA proejct and enter into it. result = cls.runner.invoke( cli, [*CLI_LOG_OPTION, "create", "--local", "myagent"], standalone_mode=False, ) assert result.exit_code == 0 os.chdir(Path(cls.t, "myagent")) cls.result = cls.runner.invoke( cli, [*CLI_LOG_OPTION, "search", "--local", "skills"], standalone_mode=False)
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() dir_path = Path("packages") tmp_dir = cls.t / dir_path src_dir = cls.cwd / Path(ROOT_DIR, dir_path) shutil.copytree(str(src_dir), str(tmp_dir)) 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", "connection", cls.resource_name], standalone_mode=False, )
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)
def setup_class(cls): """Set the test up.""" cls.runner = CliRunner() cls.agent_name = "myagent" cls.cwd = os.getcwd() cls.t = tempfile.mkdtemp() dir_path = Path("packages") tmp_dir = cls.t / dir_path src_dir = cls.cwd / Path(ROOT_DIR, dir_path) shutil.copytree(str(src_dir), str(tmp_dir)) 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 # agent's directory does not exist -> command will fail. with unittest.mock.patch.object(shutil, "rmtree", side_effect=OSError): cls.result = cls.runner.invoke( cli, [*CLI_LOG_OPTION, "delete", cls.agent_name], standalone_mode=False )
def setup_class(cls): """Set up the test class.""" cls.runner = CliRunner() cls.agent_name = "myagent" cls.cwd = os.getcwd() cls.t = tempfile.mkdtemp() dir_path = Path("packages") tmp_dir = cls.t / dir_path src_dir = cls.cwd / Path(ROOT_DIR, dir_path) shutil.copytree(str(src_dir), str(tmp_dir)) os.chdir(cls.t) # create a directory with the agent name -> make 'aea create fail. os.mkdir(cls.agent_name) 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, )
def setup_class(cls): """Set the tests up.""" cls.runner = CliRunner() cls.result = cls.runner.invoke( cli, [*CLI_LOG_OPTION, "push", "--local", "connection", "oef"], standalone_mode=False, )
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 = GymMessage.protocol_id cls.protocol_name = cls.protocol_id.name cls.protocol_author = cls.protocol_id.author cls.protocol_version = cls.protocol_id.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, ) assert result.exit_code == 0 os.chdir(cls.agent_name) result = cls.runner.invoke( cli, [ *CLI_LOG_OPTION, "add", "--local", "protocol", str(cls.protocol_id) ], standalone_mode=False, ) assert result.exit_code == 0 # add protocol again, but with different version number # first, change version number to package different_version = "0.1.1" different_id = (cls.protocol_author + "/" + cls.protocol_name + ":" + different_version) config_path = Path( cls.t, "packages", cls.protocol_author, "protocols", cls.protocol_name, DEFAULT_PROTOCOL_CONFIG_FILE, ) config = yaml.safe_load(config_path.open()) config["version"] = different_version yaml.safe_dump(config, config_path.open(mode="w")) cls.result = cls.runner.invoke( cli, [*CLI_LOG_OPTION, "add", "--local", "protocol", different_id], standalone_mode=False, )