示例#1
0
 def ensure_exists(self):
     """Ensure that cache directory exists."""
     if not cache.exists(self.config):
         logger.debug("Wily cache not found, creating.")
         cache.create(self.config)
         logger.debug("Created wily cache")
     else:
         logger.debug(f"Cache {self.config.cache_path} exists")
示例#2
0
def test_create_and_delete(tmpdir):
    """
    Test that create() will create a folder with the correct path
    and then delete it.
    """
    config = DEFAULT_CONFIG
    cache_path = pathlib.Path(tmpdir) / ".wily"
    config.cache_path = str(cache_path)
    assert not cache.exists(config)
    cache.create(config)
    assert cache.exists(config)
    cache.clean(config)
    assert not cache.exists(config)
示例#3
0
def test_create_when_exists(tmpdir):
    """
    Test that create() will continue if the folder already exists
    """
    config = DEFAULT_CONFIG
    cache_path = pathlib.Path(tmpdir) / ".wily"
    pathlib.Path(cache_path).mkdir()
    config.cache_path = str(cache_path)
    assert cache.exists(config)
    assert str(cache.create(config)) == str(cache_path)