def load( cls, working_dir: str, public_id: PublicId, is_local: bool = False, registry_path: str = "packages", skip_consistency_check: bool = False, ) -> "Project": """ Load project with given public_id to working_dir. :param working_dir: the working directory :param public_id: the public id :param is_local: whether to fetch from local or remote :param registry_path: the path to the registry locally :param skip_consistency_check: consistency checks flag """ ctx = Context(cwd=working_dir, registry_path=registry_path) ctx.set_config("skip_consistency_check", skip_consistency_check) path = os.path.join(working_dir, public_id.author, public_id.name) target_dir = os.path.join(public_id.author, public_id.name) if is_local: fetch_agent_locally(ctx, public_id, target_dir=target_dir) else: fetch_agent(ctx, public_id, target_dir=target_dir) return cls(public_id, path)
def test_fetch_agent_locally_with_deps_positive(self, *mocks): """Test for fetch_agent_locally method with deps positive result.""" public_id = PublicIdMock.from_str("author/name:0.1.0") ctx_mock = ContextMock( connections=[public_id], protocols=[public_id], skills=[public_id], contracts=[public_id], ) fetch_agent_locally(ctx_mock, PublicIdMock())
def test_fetch_agent_locally_with_deps_fail(self, *mocks): """Test for fetch_agent_locally method with deps ClickException catch.""" public_id = PublicIdMock.from_str("author/name:0.1.0") ctx_mock = ContextMock( connections=[public_id], protocols=[public_id], skills=[public_id], contracts=[public_id], ) with self.assertRaises(ClickException): fetch_agent_locally(ctx_mock, PublicIdMock())
def test_fetch_agent_locally_incorrect_version(self, *mocks): """Test for fetch_agent_locally method incorrect agent version.""" with self.assertRaises(ClickException): fetch_agent_locally(ContextMock(), PublicIdMock())
def test_fetch_agent_locally_already_exists(self, *mocks): """Test for fetch_agent_locally method agent already exists.""" with self.assertRaises(ClickException): fetch_agent_locally(ContextMock(), PublicIdMock())
def test_fetch_agent_locally_positive(self, copy_tree, *mocks): """Test for fetch_agent_locally method positive result.""" fetch_agent_locally(ContextMock(), PublicIdMock(), alias="some-alias") copy_tree.assert_called_once_with("path", "joined-path")
def test_fetch_agent_locally_incorrect_version(self, *mocks): """Test for fetch_agent_locally method incorrect agent version.""" ctx = ContextMock() ctx.config["is_local"] = True with self.assertRaises(ClickException): fetch_agent_locally(ctx, PublicIdMock())
def test_fetch_agent_locally_already_exists(self, *mocks): """Test for fetch_agent_locally method agent already exists.""" ctx = ContextMock() ctx.config["is_local"] = True with self.assertRaises(ClickException): fetch_agent_locally(ctx, PublicIdMock())