|
@@ -17,7 +17,7 @@ from ..helpers import Buffer
|
|
|
from ..helpers import partial_format, format_file_size, parse_file_size, format_timedelta, format_line, PlaceholderError, replace_placeholders
|
|
|
from ..helpers import make_path_safe, clean_lines
|
|
|
from ..helpers import interval, prune_within, prune_split
|
|
|
-from ..helpers import get_cache_dir, get_keys_dir, get_security_dir, get_config_dir
|
|
|
+from ..helpers import get_base_dir, get_cache_dir, get_keys_dir, get_security_dir, get_config_dir
|
|
|
from ..helpers import is_slow_msgpack
|
|
|
from ..helpers import yes, TRUISH, FALSISH, DEFAULTISH
|
|
|
from ..helpers import StableDict, int_to_bigint, bigint_to_int, bin_to_hex
|
|
@@ -467,6 +467,20 @@ class TestParseTimestamp(BaseTestCase):
|
|
|
self.assert_equal(parse_timestamp('2015-04-19T20:25:00'), datetime(2015, 4, 19, 20, 25, 0, 0, timezone.utc))
|
|
|
|
|
|
|
|
|
+def test_get_base_dir(monkeypatch):
|
|
|
+ """test that get_base_dir respects environment"""
|
|
|
+ monkeypatch.delenv('BORG_BASE_DIR', raising=False)
|
|
|
+ monkeypatch.delenv('HOME', raising=False)
|
|
|
+ monkeypatch.delenv('USER', raising=False)
|
|
|
+ assert get_base_dir() == os.path.expanduser('~')
|
|
|
+ monkeypatch.setenv('USER', 'root')
|
|
|
+ assert get_base_dir() == os.path.expanduser('~root')
|
|
|
+ monkeypatch.setenv('HOME', '/var/tmp/home')
|
|
|
+ assert get_base_dir() == '/var/tmp/home'
|
|
|
+ monkeypatch.setenv('BORG_BASE_DIR', '/var/tmp/base')
|
|
|
+ assert get_base_dir() == '/var/tmp/base'
|
|
|
+
|
|
|
+
|
|
|
def test_get_config_dir(monkeypatch):
|
|
|
"""test that get_config_dir respects environment"""
|
|
|
monkeypatch.delenv('BORG_CONFIG_DIR', raising=False)
|