Esempio n. 1
0
def test_fetcher() -> None:

    loader = Loader({}, fetcher_constructor=testFetcher)
    assert {"hello": "foo"} == loader.resolve_ref("foo.txt")[0]
    assert {
        "hello": "keepfoo"
    } == loader.resolve_ref("foo.txt", base_url="keep:abc+123")[0]
    assert loader.check_exists("foo.txt")

    with pytest.raises(RuntimeError):
        loader.resolve_ref("bar.txt")
    assert not loader.check_exists("bar.txt")
Esempio n. 2
0
def test_cache() -> None:
    loader = Loader({})
    foo = os.path.join(os.getcwd(), "foo.txt")
    foo = file_uri(foo)
    loader.cache.update({foo: "hello: foo"})
    print(loader.cache)
    assert {"hello": "foo"} == loader.resolve_ref("foo.txt")[0]
    assert loader.check_exists(foo)