Пример #1
0
def test_parse_resource_for_sharing_with_user(root: Root) -> None:
    full_permission = parse_resource_for_sharing(
        f"storage://{root.username}/resource", root)
    assert full_permission == URL(f"storage://{root.username}/resource")
    full_permission = parse_resource_for_sharing(f"storage://alice/resource",
                                                 root)
    assert full_permission == URL(f"storage://alice/resource")
Пример #2
0
def test_parse_resource_for_sharing_unsupported_scheme(root: Root) -> None:
    with pytest.raises(ValueError, match=r"Unsupported URI scheme"):
        parse_resource_for_sharing("http://neuromation.io", root)
    with pytest.raises(ValueError, match=r"Unsupported URI scheme"):
        parse_resource_for_sharing("file:///etc/password", root)
    with pytest.raises(ValueError, match=r"Unsupported URI scheme"):
        parse_resource_for_sharing(r"c:scheme-less/resource", root)
Пример #3
0
def test_parse_resource_for_sharing_with_tilde_relative(root: Root) -> None:
    with pytest.raises(ValueError, match=r"Cannot expand user for "):
        parse_resource_for_sharing(f"storage:~/resource", root)
Пример #4
0
def test_parse_resource_for_sharing_user_less(root: Root) -> None:
    user_less_permission = parse_resource_for_sharing("storage:resource", root)
    assert user_less_permission == URL(
        f"storage://{root.client.cluster_name}/{root.client.username}/resource"
    )
Пример #5
0
def test_parse_resource_for_sharing_no_scheme(root: Root) -> None:
    with pytest.raises(ValueError, match=r"URI Scheme not specified"):
        parse_resource_for_sharing("scheme-less/resource", root)
Пример #6
0
def test_parse_resource_for_sharing_image_with_tag_fail(root: Root) -> None:
    uri = "image://~/ubuntu:latest"
    with pytest.raises(ValueError, match="tag is not allowed"):
        parse_resource_for_sharing(uri, root)
Пример #7
0
def test_parse_resource_for_sharing_image_no_tag(root: Root) -> None:
    uri = "image:ubuntu"
    parsed = parse_resource_for_sharing(uri, root)
    assert parsed == URL(
        f"image://{root.client.cluster_name}/{root.client.username}/ubuntu"
    )
Пример #8
0
def test_parse_resource_for_sharing_with_tilde(root: Root) -> None:
    parsed = parse_resource_for_sharing(f"storage://~/resource", root)
    assert parsed == URL(f"storage://{root.username}/resource")