Beispiel #1
0
def test_cache_expiration(fake_output_dir):
    new_file = os.path.join(fake_output_dir, "test.file")
    with open(new_file, "w") as f:
        f.write("foo")
    random_data = {k: random.randint(0, 10) for k in "abcdefghijklmnop"}
    cache_data(random_data, fake_output_dir)
    time.sleep(0.5)
    with open(new_file, "w") as f:
        f.write("bar")
    assert not check_cache_directory(fake_output_dir)
Beispiel #2
0
def test_cache_expiration(fake_output_dir):
    new_file = os.path.join(fake_output_dir, "test.file")
    with open(new_file, "w") as f:
        f.write("foo")
    random_data = {k: random.randint(0, 10) for k in "abcdefghijklmnop"}
    cache_data(random_data, fake_output_dir)
    time.sleep(0.5)
    with open(new_file, "w") as f:
        f.write("bar")
    assert not check_cache_directory(fake_output_dir)
Beispiel #3
0
def test_cache_loading(fake_output_dir):
    random_data = {k: random.randint(0, 10) for k in "abcdefghijklmnop"}
    fp = os.path.abspath(__file__)
    cache_data(random_data, fp)
    assert random_data == get_from_cache(fp)
Beispiel #4
0
def test_cache_loading(fake_output_dir):
    tempdir.reset()
    random_data = {k: random.randint(0, 10) for k in "abcdefghijklmnop"}
    fp = os.path.abspath(__file__)
    cache_data(random_data, fp)
    assert random_data == get_from_cache(fp)