def test_we_cache_files(self, assets_ini, loader): cached = _CachedFile(assets_ini, loader) cached.load() contents = cached.load() loader.assert_called_once() assert contents == self.ASSET_INI_CONTENTS
def test_we_auto_reload_if_the_mtime_changes_aith_auto_reload_True( self, assets_ini, loader): cached = _CachedFile(assets_ini, loader, auto_reload=True) cached.load() self.age_file(assets_ini, -2000) # 2 seconds into the future cached.load() assert loader.call_count == 2
def test_we_read_from_the_cache_if_the_mtime_changes( self, assets_ini, loader): cached = _CachedFile(assets_ini, loader, auto_reload=False) cached.load() self.age_file(assets_ini, -2000) # 2 seconds into the future cached.load() assert loader.call_count == 1
def test_we_check_paths_when_created(self, loader): with pytest.raises(FileNotFoundError): _CachedFile("not_a_file.txt", loader)
def test_we_can_load_a_file_outside_of_our_package(self, dockerfile, loader): cached = _CachedFile(dockerfile, loader) contents = cached.load() assert contents == self.DOCKER_FILE_CONTENTS
def test_we_can_load_a_file(self, assets_ini, loader): cached = _CachedFile(assets_ini, loader) contents = cached.load() assert contents == self.ASSET_INI_CONTENTS