瀏覽代碼

Add tests for Location.with_timestamp

Milkey Mouse 4 年之前
父節點
當前提交
3644bd14dc
共有 1 個文件被更改,包括 8 次插入0 次删除
  1. 8 0
      src/borg/testsuite/helpers.py

+ 8 - 0
src/borg/testsuite/helpers.py

@@ -189,6 +189,10 @@ class TestLocationWithoutEnv:
         assert repr(Location('ssh://host/path::2016-12-31@23:59:59')) == \
             "Location(proto='ssh', user=None, host='host', port=None, path='/path', archive='2016-12-31@23:59:59')"
 
+    def test_with_timestamp(self):
+        assert repr(Location('path::archive-{utcnow}').with_timestamp(datetime(2002, 9, 19))) == \
+            "Location(proto='file', user=None, host=None, port=None, path='path', archive='archive-2002-09-19T00:00:00')"
+
     def test_underspecified(self, monkeypatch):
         monkeypatch.delenv('BORG_REPO', raising=False)
         with pytest.raises(ValueError):
@@ -935,6 +939,10 @@ def test_replace_placeholders():
     assert int(replace_placeholders('{now:%Y}')) == now.year
 
 
+def test_override_placeholders():
+    assert replace_placeholders('{uuid4}', overrides={'uuid4': "overridden"}) == "overridden"
+
+
 def working_swidth():
     return platform.swidth('선') == 2