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)
def test_cache_directory_error(monkeypatch): monkeypatch.setattr( 'ocelot.filesystem.get_cache_filepath_for_data_path', lambda x: "not a real thing" ) assert not check_cache_directory(os.getcwd())