Exemple #1
0
def test_get_relative_url_with_file_object(tmpdir):
    repo = FileRepository(id="some-repo")
    file_obj = StringIO()

    with pytest.raises(ValueError):
        repo._get_relative_url(file_obj, None)

    with pytest.raises(ValueError):
        repo._get_relative_url(file_obj, "some/path/")

    assert repo._get_relative_url(file_obj, "path/foo.txt") == "path/foo.txt"
Exemple #2
0
def test_get_relative_url(tmpdir, relative_url, expected):
    somefile = tmpdir.join("some-file.txt")
    repo = FileRepository(id="some-repo")
    result = repo._get_relative_url(str(somefile), relative_url)

    assert result == expected