Example #1
0
def test_web_properties():
    src = "https://example.com/hello/world.mp3?foo=bar#bookmark"
    p = resolve_path(src)
    assert p.raw == src
    assert p.canonical == src
    assert p.basename == "world.mp3"
    assert p.fileext == "mp3"

    # test that urlunparse removes redundancies
    q = resolve_path("https://example.com/data.json?")
    assert q.raw == "https://example.com/data.json?"
    assert q.canonical == "https://example.com/data.json"
    assert q.basename == "data.json"
    assert q.fileext == "json"
Example #2
0
def test_file_properties():
    src = "~/Downloads/hello/world.mp3"
    p = resolve_path(src)

    assert p.raw == src
    assert p.canonical == str(Path(src).expanduser().resolve())
    assert p.basename == "world.mp3"
    assert p.fileext == "mp3"
Example #3
0
def test_s3_properties():
    src = "s3://my.bucket.123/hello/world.mp3"
    p = resolve_path(src)

    assert p.raw == src
    assert p.canonical == src
    assert p.basename == "world.mp3"
    assert p.fileext == "mp3"

    assert p.bucket == "my.bucket.123"
    assert p.key == "hello/world.mp3"
Example #4
0
def test_s3_exists():
    p = resolve_path("s3://mybucket/this/exists.mp3")
    assert p.exists() is True

    q = resolve_path("s3://mybucket/this/doesnt/exist.mp3")
    assert p.exists() is False
Example #5
0
def test_s3_properties_edgecase():
    src = "s3://my.bucket.123/hello/world.foo#bar.mp3?awsProp=12345"
    p = resolve_path(src)
    assert p.basename == "world.foo#bar.mp3"
    assert p.fileext == "mp3"
Example #6
0
def test_resolve_file_path_string():
    src = "~/Downloads/hello/world.mp3"
    p = resolve_path(src)
    assert type(p) is File
Example #7
0
def test_file_exists():
    p = resolve_path("this/does/exist.mp3")
    assert p.exists() is True

    q = resolve_path("this/does/not-exist.mp3")
    assert p.exists() is False
Example #8
0
def test_resolve_web_path_from_urlparse():
    src = "https://example.com/hello/world.mp3"
    p = resolve_path(src)
    assert type(p) is Web
Example #9
0
def test_resolve_s3_path_from_urlparse():
    src = urlparse("s3://my.bucket.123/hello/world.mp3")
    p = resolve_path(src)
    assert type(p) is S3
Example #10
0
def test_resolve_s3_path():
    src = "s3://my.bucket.123/path/to/key.json"
    p = resolve_path(src)
    assert type(p) is S3
Example #11
0
def test_resolve_file_path_from_path_object():
    src = Path("~/Downloads/hello/world.mp3")
    p = resolve_path(src)
    assert type(p) is File
Example #12
0
def test_web_exists():
    p = resolve_path("http://example.com/stuff.mp3")
    assert p.exists() is True

    q = resolve_path("http://example.com/not-here.mp3")
    assert p.exists() is False