Changeset - c7fbf5b5d586
[Not reviewed]
0 3 0
Brett Smith - 4 years ago 2020-04-10 12:24:34
brettcsmith@brettcsmith.org
config: s/XDG_CACHE_DIR/XDG_CACHE_HOME/g

Per the spec.
3 files changed with 10 insertions and 10 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/config.py
Show inline comments
...
 
@@ -79,7 +79,7 @@ class Config:
 

	
 
    def cache_dir_path(self, name: str='conservancy_beancount') -> Optional[Path]:
 
        try:
 
            cache_root = Path(os.environ['XDG_CACHE_DIR'])
 
            cache_root = Path(os.environ['XDG_CACHE_HOME'])
 
        except (KeyError, ValueError):
 
            cache_root = Path.home() / '.cache'
 
        return (
tests/conftest.py
Show inline comments
...
 
@@ -12,4 +12,4 @@ def clean_environment(tmpdir_factory):
 
    os.environ.pop('RTUSER', None)
 
    os.environ['CONSERVANCY_REPOSITORY'] = str(testutil.test_path('repository'))
 
    os.environ['HOME'] = str(testutil.test_path('userconfig'))
 
    os.environ['XDG_CACHE_DIR'] = str(tmpdir_factory.mktemp('.cache'))
 
    os.environ['XDG_CACHE_HOME'] = str(tmpdir_factory.mktemp('.cache'))
tests/test_config.py
Show inline comments
...
 
@@ -217,7 +217,7 @@ def test_rt_wrapper_cache_responds_to_external_credential_changes(rt_environ):
 
    assert rt1 is not rt2
 

	
 
def test_rt_wrapper_has_cache(tmp_path):
 
    with update_environ(XDG_CACHE_DIR=tmp_path), update_umask(0o002):
 
    with update_environ(XDG_CACHE_HOME=tmp_path), update_umask(0o002):
 
        config = config_mod.Config()
 
        rt = config.rt_wrapper(None, testutil.RTClient)
 
        rt.exists(1)
...
 
@@ -229,7 +229,7 @@ def test_rt_wrapper_has_cache(tmp_path):
 

	
 
def test_rt_wrapper_without_cache(tmp_path):
 
    tmp_path.chmod(0)
 
    with update_environ(XDG_CACHE_DIR=tmp_path):
 
    with update_environ(XDG_CACHE_HOME=tmp_path):
 
        config = config_mod.Config()
 
        rt = config.rt_wrapper(None, testutil.RTClient)
 
    tmp_path.chmod(0o600)
...
 
@@ -237,7 +237,7 @@ def test_rt_wrapper_without_cache(tmp_path):
 

	
 
def test_cache_mkdir(tmp_path):
 
    expected = tmp_path / 'TESTcache'
 
    with update_environ(XDG_CACHE_DIR=tmp_path):
 
    with update_environ(XDG_CACHE_HOME=tmp_path):
 
        config = config_mod.Config()
 
        cache_path = config.cache_dir_path(expected.name)
 
    assert cache_path == tmp_path / 'TESTcache'
...
 
@@ -246,7 +246,7 @@ def test_cache_mkdir(tmp_path):
 
def test_cache_mkdir_parent(tmp_path):
 
    xdg_cache_dir = tmp_path / 'xdgcache'
 
    expected = xdg_cache_dir / 'conservancy_beancount'
 
    with update_environ(XDG_CACHE_DIR=xdg_cache_dir):
 
    with update_environ(XDG_CACHE_HOME=xdg_cache_dir):
 
        config = config_mod.Config()
 
        cache_path = config.cache_dir_path(expected.name)
 
    assert cache_path == expected
...
 
@@ -254,7 +254,7 @@ def test_cache_mkdir_parent(tmp_path):
 

	
 
def test_cache_mkdir_from_home(tmp_path):
 
    expected = tmp_path / '.cache' / 'TESTcache'
 
    with update_environ(HOME=tmp_path, XDG_CACHE_DIR=None):
 
    with update_environ(HOME=tmp_path, XDG_CACHE_HOME=None):
 
        config = config_mod.Config()
 
        cache_path = config.cache_dir_path(expected.name)
 
    assert cache_path == expected
...
 
@@ -263,7 +263,7 @@ def test_cache_mkdir_from_home(tmp_path):
 
def test_cache_mkdir_exists_ok(tmp_path):
 
    expected = tmp_path / 'TESTcache'
 
    expected.mkdir()
 
    with update_environ(XDG_CACHE_DIR=tmp_path):
 
    with update_environ(XDG_CACHE_HOME=tmp_path):
 
        config = config_mod.Config()
 
        cache_path = config.cache_dir_path(expected.name)
 
    assert cache_path == expected
...
 
@@ -271,7 +271,7 @@ def test_cache_mkdir_exists_ok(tmp_path):
 
def test_cache_path_conflict(tmp_path):
 
    extant_path = tmp_path / 'TESTcache'
 
    extant_path.touch()
 
    with update_environ(XDG_CACHE_DIR=tmp_path):
 
    with update_environ(XDG_CACHE_HOME=tmp_path):
 
        config = config_mod.Config()
 
        cache_path = config.cache_dir_path(extant_path.name)
 
    assert cache_path is None
...
 
@@ -279,7 +279,7 @@ def test_cache_path_conflict(tmp_path):
 

	
 
def test_cache_path_parent_conflict(tmp_path):
 
    (tmp_path / '.cache').touch()
 
    with update_environ(HOME=tmp_path, XDG_CACHE_DIR=None):
 
    with update_environ(HOME=tmp_path, XDG_CACHE_HOME=None):
 
        config = config_mod.Config()
 
        assert config.cache_dir_path('TESTcache') is None
 

	
0 comments (0 inline, 0 general)