config: s/XDG_CACHE_DIR/XDG_CACHE_HOME/g
Per the spec.
This commit is contained in:
parent
9f0c30738d
commit
c7fbf5b5d5
3 changed files with 10 additions and 10 deletions
|
@ -79,7 +79,7 @@ class Config:
|
||||||
|
|
||||||
def cache_dir_path(self, name: str='conservancy_beancount') -> Optional[Path]:
|
def cache_dir_path(self, name: str='conservancy_beancount') -> Optional[Path]:
|
||||||
try:
|
try:
|
||||||
cache_root = Path(os.environ['XDG_CACHE_DIR'])
|
cache_root = Path(os.environ['XDG_CACHE_HOME'])
|
||||||
except (KeyError, ValueError):
|
except (KeyError, ValueError):
|
||||||
cache_root = Path.home() / '.cache'
|
cache_root = Path.home() / '.cache'
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -12,4 +12,4 @@ def clean_environment(tmpdir_factory):
|
||||||
os.environ.pop('RTUSER', None)
|
os.environ.pop('RTUSER', None)
|
||||||
os.environ['CONSERVANCY_REPOSITORY'] = str(testutil.test_path('repository'))
|
os.environ['CONSERVANCY_REPOSITORY'] = str(testutil.test_path('repository'))
|
||||||
os.environ['HOME'] = str(testutil.test_path('userconfig'))
|
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'))
|
||||||
|
|
|
@ -217,7 +217,7 @@ def test_rt_wrapper_cache_responds_to_external_credential_changes(rt_environ):
|
||||||
assert rt1 is not rt2
|
assert rt1 is not rt2
|
||||||
|
|
||||||
def test_rt_wrapper_has_cache(tmp_path):
|
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()
|
config = config_mod.Config()
|
||||||
rt = config.rt_wrapper(None, testutil.RTClient)
|
rt = config.rt_wrapper(None, testutil.RTClient)
|
||||||
rt.exists(1)
|
rt.exists(1)
|
||||||
|
@ -229,7 +229,7 @@ def test_rt_wrapper_has_cache(tmp_path):
|
||||||
|
|
||||||
def test_rt_wrapper_without_cache(tmp_path):
|
def test_rt_wrapper_without_cache(tmp_path):
|
||||||
tmp_path.chmod(0)
|
tmp_path.chmod(0)
|
||||||
with update_environ(XDG_CACHE_DIR=tmp_path):
|
with update_environ(XDG_CACHE_HOME=tmp_path):
|
||||||
config = config_mod.Config()
|
config = config_mod.Config()
|
||||||
rt = config.rt_wrapper(None, testutil.RTClient)
|
rt = config.rt_wrapper(None, testutil.RTClient)
|
||||||
tmp_path.chmod(0o600)
|
tmp_path.chmod(0o600)
|
||||||
|
@ -237,7 +237,7 @@ def test_rt_wrapper_without_cache(tmp_path):
|
||||||
|
|
||||||
def test_cache_mkdir(tmp_path):
|
def test_cache_mkdir(tmp_path):
|
||||||
expected = tmp_path / 'TESTcache'
|
expected = tmp_path / 'TESTcache'
|
||||||
with update_environ(XDG_CACHE_DIR=tmp_path):
|
with update_environ(XDG_CACHE_HOME=tmp_path):
|
||||||
config = config_mod.Config()
|
config = config_mod.Config()
|
||||||
cache_path = config.cache_dir_path(expected.name)
|
cache_path = config.cache_dir_path(expected.name)
|
||||||
assert cache_path == tmp_path / 'TESTcache'
|
assert cache_path == tmp_path / 'TESTcache'
|
||||||
|
@ -246,7 +246,7 @@ def test_cache_mkdir(tmp_path):
|
||||||
def test_cache_mkdir_parent(tmp_path):
|
def test_cache_mkdir_parent(tmp_path):
|
||||||
xdg_cache_dir = tmp_path / 'xdgcache'
|
xdg_cache_dir = tmp_path / 'xdgcache'
|
||||||
expected = xdg_cache_dir / 'conservancy_beancount'
|
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()
|
config = config_mod.Config()
|
||||||
cache_path = config.cache_dir_path(expected.name)
|
cache_path = config.cache_dir_path(expected.name)
|
||||||
assert cache_path == expected
|
assert cache_path == expected
|
||||||
|
@ -254,7 +254,7 @@ def test_cache_mkdir_parent(tmp_path):
|
||||||
|
|
||||||
def test_cache_mkdir_from_home(tmp_path):
|
def test_cache_mkdir_from_home(tmp_path):
|
||||||
expected = tmp_path / '.cache' / 'TESTcache'
|
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()
|
config = config_mod.Config()
|
||||||
cache_path = config.cache_dir_path(expected.name)
|
cache_path = config.cache_dir_path(expected.name)
|
||||||
assert cache_path == expected
|
assert cache_path == expected
|
||||||
|
@ -263,7 +263,7 @@ def test_cache_mkdir_from_home(tmp_path):
|
||||||
def test_cache_mkdir_exists_ok(tmp_path):
|
def test_cache_mkdir_exists_ok(tmp_path):
|
||||||
expected = tmp_path / 'TESTcache'
|
expected = tmp_path / 'TESTcache'
|
||||||
expected.mkdir()
|
expected.mkdir()
|
||||||
with update_environ(XDG_CACHE_DIR=tmp_path):
|
with update_environ(XDG_CACHE_HOME=tmp_path):
|
||||||
config = config_mod.Config()
|
config = config_mod.Config()
|
||||||
cache_path = config.cache_dir_path(expected.name)
|
cache_path = config.cache_dir_path(expected.name)
|
||||||
assert cache_path == expected
|
assert cache_path == expected
|
||||||
|
@ -271,7 +271,7 @@ def test_cache_mkdir_exists_ok(tmp_path):
|
||||||
def test_cache_path_conflict(tmp_path):
|
def test_cache_path_conflict(tmp_path):
|
||||||
extant_path = tmp_path / 'TESTcache'
|
extant_path = tmp_path / 'TESTcache'
|
||||||
extant_path.touch()
|
extant_path.touch()
|
||||||
with update_environ(XDG_CACHE_DIR=tmp_path):
|
with update_environ(XDG_CACHE_HOME=tmp_path):
|
||||||
config = config_mod.Config()
|
config = config_mod.Config()
|
||||||
cache_path = config.cache_dir_path(extant_path.name)
|
cache_path = config.cache_dir_path(extant_path.name)
|
||||||
assert cache_path is None
|
assert cache_path is None
|
||||||
|
@ -279,7 +279,7 @@ def test_cache_path_conflict(tmp_path):
|
||||||
|
|
||||||
def test_cache_path_parent_conflict(tmp_path):
|
def test_cache_path_parent_conflict(tmp_path):
|
||||||
(tmp_path / '.cache').touch()
|
(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()
|
config = config_mod.Config()
|
||||||
assert config.cache_dir_path('TESTcache') is None
|
assert config.cache_dir_path('TESTcache') is None
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue