clan_uri: Support all other formats by just differentiating between remote and local
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from clan_cli.clan_uri import ClanParameters, ClanScheme, ClanURI
|
||||
from clan_cli.errors import ClanError
|
||||
|
||||
|
||||
def test_get_internal() -> None:
|
||||
@@ -25,24 +22,18 @@ def test_local_uri() -> None:
|
||||
# Create a ClanURI object from a local URI
|
||||
uri = ClanURI("clan://file:///home/user/Downloads")
|
||||
match uri.scheme:
|
||||
case ClanScheme.FILE.value(path):
|
||||
case ClanScheme.LOCAL.value(path):
|
||||
assert path == Path("/home/user/Downloads") # type: ignore
|
||||
case _:
|
||||
assert False
|
||||
|
||||
|
||||
def test_unsupported_schema() -> None:
|
||||
with pytest.raises(ClanError, match="Unsupported uri components: .*"):
|
||||
# Create a ClanURI object from an unsupported URI
|
||||
ClanURI("clan://ftp://ftp.example.com")
|
||||
|
||||
|
||||
def test_is_remote() -> None:
|
||||
# Create a ClanURI object from a remote URI
|
||||
uri = ClanURI("clan://https://example.com")
|
||||
|
||||
match uri.scheme:
|
||||
case ClanScheme.HTTP.value(url):
|
||||
case ClanScheme.REMOTE.value(url):
|
||||
assert url == "https://example.com" # type: ignore
|
||||
case _:
|
||||
assert False
|
||||
@@ -67,7 +58,7 @@ def test_remote_with_clanparams() -> None:
|
||||
assert uri.params.flake_attr == "defaultVM"
|
||||
|
||||
match uri.scheme:
|
||||
case ClanScheme.HTTP.value(url):
|
||||
case ClanScheme.REMOTE.value(url):
|
||||
assert url == "https://example.com" # type: ignore
|
||||
case _:
|
||||
assert False
|
||||
@@ -81,7 +72,7 @@ def test_from_path_with_custom() -> None:
|
||||
assert uri.params.flake_attr == "myVM"
|
||||
|
||||
match uri.scheme:
|
||||
case ClanScheme.FILE.value(path):
|
||||
case ClanScheme.LOCAL.value(path):
|
||||
assert path == Path("/home/user/Downloads") # type: ignore
|
||||
case _:
|
||||
assert False
|
||||
@@ -95,7 +86,7 @@ def test_from_path_with_default() -> None:
|
||||
assert uri.params.flake_attr == "defaultVM"
|
||||
|
||||
match uri.scheme:
|
||||
case ClanScheme.FILE.value(path):
|
||||
case ClanScheme.LOCAL.value(path):
|
||||
assert path == Path("/home/user/Downloads") # type: ignore
|
||||
case _:
|
||||
assert False
|
||||
@@ -109,7 +100,7 @@ def test_from_str() -> None:
|
||||
assert uri.params.flake_attr == "myVM"
|
||||
|
||||
match uri.scheme:
|
||||
case ClanScheme.HTTP.value(url):
|
||||
case ClanScheme.REMOTE.value(url):
|
||||
assert url == "https://example.com?password=asdasd&test=1234" # type: ignore
|
||||
case _:
|
||||
assert False
|
||||
@@ -137,7 +128,7 @@ def test_remote_with_all_params() -> None:
|
||||
assert uri.params.flake_attr == "myVM"
|
||||
|
||||
match uri.scheme:
|
||||
case ClanScheme.HTTP.value(url):
|
||||
case ClanScheme.REMOTE.value(url):
|
||||
assert url == "https://example.com?password=1234" # type: ignore
|
||||
case _:
|
||||
assert False
|
||||
|
||||
Reference in New Issue
Block a user