def test_parse_file_resource_with_user(root: Root) -> None: full_permission = parse_file_resource( f"storage://{root.client.cluster_name}/{root.client.username}/resource", root ) assert full_permission == URL( f"storage://{root.client.cluster_name}/{root.client.username}/resource" ) full_permission = parse_file_resource(f"storage://default/alice/resource", root) assert full_permission == URL(f"storage://default/alice/resource")
def test_parse_file_resource_with_tilde(root: Root) -> None: with pytest.raises(ValueError, match=r"Cannot expand user for "): parse_file_resource(f"storage://~/resource", root)
def test_parse_file_resource_user_less(root: Root) -> None: user_less_permission = parse_file_resource("storage:resource", root) assert user_less_permission == URL( f"storage://{root.client.cluster_name}/{root.client.username}/resource" )
def test_parse_file_resource_unsupported_scheme(root: Root) -> None: with pytest.raises(ValueError, match=r"Unsupported URI scheme"): parse_file_resource("http://neuromation.io", root) with pytest.raises(ValueError, match=r"Unsupported URI scheme"): parse_file_resource("image:ubuntu", root)
def test_parse_file_resource_no_scheme(root: Root) -> None: parsed = parse_file_resource("scheme-less/resource", root) assert parsed == URL((Path.cwd() / "scheme-less/resource").as_uri()) parsed = parse_file_resource("c:scheme-less/resource", root) assert parsed == URL((Path("c:scheme-less").resolve() / "resource").as_uri())
def test_parse_file_resource_with_tilde(root: Root) -> None: parsed = parse_file_resource(f"storage://~/resource", root) assert parsed == URL(f"storage://{root.username}/resource")