Esempio n. 1
0
def test_package_id_from_uri_path_negative():
    """Test PackageId.from_uri_path with invalid type"""
    with pytest.raises(
            ValueError,
            match=
            "Input 'not_a_valid_type/author/package_name/0.1.0' is not well formatted.",
    ):
        PackageId.from_uri_path("not_a_valid_type/author/package_name/0.1.0")
Esempio n. 2
0
    def _get_public_ids_from_uri(
        uri: URI, ) -> Tuple[Optional[PublicId], Optional[PublicId]]:
        """
        Try get skill and connection id from uri.

        :param uri: the uri
        :return: (skill_id if present in uri, connection if present in uri)
        """
        skill_id = None
        connection_id = None
        try:
            package_id = PackageId.from_uri_path(uri.path)
            package_type = str(package_id.package_type)
            if package_type == "skill":
                skill_id = package_id.public_id
            elif package_type == "connection":
                connection_id = package_id.public_id
            else:
                raise ValueError(
                    f"Invalid package type {package_type} in uri for envelope context."
                )
        except ValueError as e:
            _default_logger.debug(
                f"URI - {uri.path} - not a valid package_id id. Error: {e}")
        return (skill_id, connection_id)
Esempio n. 3
0
def test_package_id_from_uri_path():
    """Test PackageId.from_uri_path"""
    result = PackageId.from_uri_path("skill/author/package_name/0.1.0")
    assert str(result.package_type) == "skill"
    assert result.public_id.name == "package_name"
    assert result.public_id.author == "author"
    assert result.public_id.version == "0.1.0"
Esempio n. 4
0
def test_agent_config_to_json_with_optional_configurations():
    """Test agent config to json with optional configurations."""
    agent_config = AgentConfig(
        "name",
        "author",
        period=0.1,
        execution_timeout=1.0,
        max_reactions=100,
        decision_maker_handler=dict(dotted_path="", file_path=""),
        error_handler=dict(dotted_path="", file_path=""),
        skill_exception_policy="propagate",
        connection_exception_policy="propagate",
        default_routing={"author/name:0.1.0": "author/name:0.1.0"},
        currency_denominations={"fetchai": "fet"},
        loop_mode="sync",
        runtime_mode="async",
        storage_uri="some_uri_to_storage",
    )
    agent_config.default_connection = "author/name:0.1.0"
    agent_config.default_ledger = DEFAULT_LEDGER
    agent_config.json
    assert agent_config.package_id == PackageId.from_uri_path(
        "agent/author/name/0.1.0")