Browse Source

move return codes tests to own module

Thomas Waldmann 2 years ago
parent
commit
3c247b8109
2 changed files with 20 additions and 18 deletions
  1. 0 18
      src/borg/testsuite/archiver/__init__.py
  2. 20 0
      src/borg/testsuite/archiver/return_codes.py

+ 0 - 18
src/borg/testsuite/archiver/__init__.py

@@ -134,24 +134,6 @@ def cmd(request):
     return exec_fn
 
 
-def test_return_codes(cmd, tmpdir):
-    repo = tmpdir.mkdir("repo")
-    input = tmpdir.mkdir("input")
-    output = tmpdir.mkdir("output")
-    input.join("test_file").write("content")
-    rc, out = cmd("--repo=%s" % str(repo), "rcreate", "--encryption=none")
-    assert rc == EXIT_SUCCESS
-    rc, out = cmd("--repo=%s" % repo, "create", "archive", str(input))
-    assert rc == EXIT_SUCCESS
-    with changedir(str(output)):
-        rc, out = cmd("--repo=%s" % repo, "extract", "archive")
-        assert rc == EXIT_SUCCESS
-    rc, out = cmd("--repo=%s" % repo, "extract", "archive", "does/not/match")
-    assert rc == EXIT_WARNING  # pattern did not match
-    rc, out = cmd("--repo=%s" % repo, "create", "archive", str(input))
-    assert rc == EXIT_ERROR  # duplicate archive name
-
-
 """
 test_disk_full is very slow and not recommended to be included in daily testing.
 for this test, an empty, writable 16MB filesystem mounted on DF_MOUNT is required.

+ 20 - 0
src/borg/testsuite/archiver/return_codes.py

@@ -0,0 +1,20 @@
+from ...constants import *  # NOQA
+from . import cmd, changedir
+
+
+def test_return_codes(cmd, tmpdir):
+    repo = tmpdir.mkdir("repo")
+    input = tmpdir.mkdir("input")
+    output = tmpdir.mkdir("output")
+    input.join("test_file").write("content")
+    rc, out = cmd("--repo=%s" % str(repo), "rcreate", "--encryption=none")
+    assert rc == EXIT_SUCCESS
+    rc, out = cmd("--repo=%s" % repo, "create", "archive", str(input))
+    assert rc == EXIT_SUCCESS
+    with changedir(str(output)):
+        rc, out = cmd("--repo=%s" % repo, "extract", "archive")
+        assert rc == EXIT_SUCCESS
+    rc, out = cmd("--repo=%s" % repo, "extract", "archive", "does/not/match")
+    assert rc == EXIT_WARNING  # pattern did not match
+    rc, out = cmd("--repo=%s" % repo, "create", "archive", str(input))
+    assert rc == EXIT_ERROR  # duplicate archive name