示例#1
0
def parse_registry_uri(uri: str) -> RegistryURI:
    """
    Validate and return (authority, pkg name, version) from a valid registry URI
    """
    validate_registry_uri(uri)
    parsed_uri = parse.urlparse(uri)
    authority = parsed_uri.netloc
    pkg_name = parsed_uri.path.strip("/")
    pkg_version = parsed_uri.query.lstrip("version=").strip("/")
    return RegistryURI(authority, pkg_name, pkg_version)
示例#2
0
 def from_registry(cls, registry_uri: str, w3: Web3) -> "Package":
     """
     Instantiate a Package object from a valid Registry URI.
     --
     Requires a web3 object connected to the chain the registry lives on.
     """
     validate_registry_uri(registry_uri)
     manifest_uri = lookup_manifest_uri_located_at_registry_uri(registry_uri, w3)
     manifest_data = get_manifest_from_content_addressed_uri(manifest_uri)
     return cls(manifest_data, w3)
示例#3
0
def test_is_registry_uri_validates(uri):
    assert validate_registry_uri(uri) is None
示例#4
0
def test_is_registry_uri_raises_exception_for_invalid_uris(uri):
    with pytest.raises(UriNotSupportedError):
        validate_registry_uri(uri)
示例#5
0
def test_is_registry_uri_raises_exception_for_invalid_uris(uri):
    with pytest.raises(ValidationError):
        validate_registry_uri(uri)