瀏覽代碼

info_cmd converted, edited generate tests comment

bigtedde 1 年之前
父節點
當前提交
725149cb8b

+ 1 - 1
src/borg/testsuite/archiver/create_cmd.py

@@ -44,7 +44,7 @@ from . import (
 
 
 def pytest_generate_tests(metafunc):
-    # Generates tests that run on local and remote repos, as well as with a binary base.
+    # Generate tests for different scenarios: local repository, remote repository, and using the borg binary.
     if "archivers" in metafunc.fixturenames:
         metafunc.parametrize("archivers", ["archiver", "remote_archiver", "binary_archiver"])
 

+ 1 - 1
src/borg/testsuite/archiver/debug_cmds.py

@@ -9,7 +9,7 @@ from . import cmd, create_test_files, create_regular_file, RK_ENCRYPTION
 
 
 def pytest_generate_tests(metafunc):
-    # Generates tests that run on local and remote repos, as well as with a binary base.
+    # Generate tests for different scenarios: local repository, remote repository, and using the borg binary.
     if "archivers" in metafunc.fixturenames:
         metafunc.parametrize("archivers", ["archiver", "remote_archiver", "binary_archiver"])
 

+ 1 - 1
src/borg/testsuite/archiver/delete_cmd.py

@@ -6,7 +6,7 @@ from . import cmd, create_regular_file, RK_ENCRYPTION, src_file, create_src_arch
 
 
 def pytest_generate_tests(metafunc):
-    # Generates tests that run on local and remote repos, as well as with a binary base.
+    # Generate tests for different scenarios: local repository, remote repository, and using the borg binary.
     if "archivers" in metafunc.fixturenames:
         metafunc.parametrize("archivers", ["archiver", "remote_archiver", "binary_archiver"])
 

+ 1 - 1
src/borg/testsuite/archiver/diff_cmd.py

@@ -10,7 +10,7 @@ from . import cmd, create_regular_file, RK_ENCRYPTION, assert_line_exists
 
 
 def pytest_generate_tests(metafunc):
-    # Generates tests that run on local and remote repos, as well as with a binary base.
+    # Generate tests for different scenarios: local repository, remote repository, and using the borg binary.
     if "archivers" in metafunc.fixturenames:
         metafunc.parametrize("archivers", ["archiver", "remote_archiver", "binary_archiver"])
 

+ 1 - 1
src/borg/testsuite/archiver/extract_cmd.py

@@ -27,7 +27,7 @@ from . import (
 
 
 def pytest_generate_tests(metafunc):
-    # Generates tests that run on local and remote repos, as well as with a binary base.
+    # Generate tests for different scenarios: local repository, remote repository, and using the borg binary.
     if "archivers" in metafunc.fixturenames:
         metafunc.parametrize("archivers", ["archiver", "remote_archiver", "binary_archiver"])
 

+ 50 - 54
src/borg/testsuite/archiver/info_cmd.py

@@ -1,58 +1,54 @@
 import json
 import os
-import unittest
 
 from ...constants import *  # NOQA
-from . import (
-    ArchiverTestCaseBase,
-    RemoteArchiverTestCaseBase,
-    ArchiverTestCaseBinaryBase,
-    RK_ENCRYPTION,
-    checkts,
-    BORG_EXES,
-)
-
-
-class ArchiverTestCase(ArchiverTestCaseBase):
-    def test_info(self):
-        self.create_regular_file("file1", size=1024 * 80)
-        self.cmd(f"--repo={self.repository_location}", "rcreate", RK_ENCRYPTION)
-        self.cmd(f"--repo={self.repository_location}", "create", "test", "input")
-        info_archive = self.cmd(f"--repo={self.repository_location}", "info", "-a", "test")
-        assert "Archive name: test" + os.linesep in info_archive
-        info_archive = self.cmd(f"--repo={self.repository_location}", "info", "--first", "1")
-        assert "Archive name: test" + os.linesep in info_archive
-
-    def test_info_json(self):
-        self.create_regular_file("file1", size=1024 * 80)
-        self.cmd(f"--repo={self.repository_location}", "rcreate", RK_ENCRYPTION)
-        self.cmd(f"--repo={self.repository_location}", "create", "test", "input")
-
-        info_archive = json.loads(self.cmd(f"--repo={self.repository_location}", "info", "-a", "test", "--json"))
-        archives = info_archive["archives"]
-        assert len(archives) == 1
-        archive = archives[0]
-        assert archive["name"] == "test"
-        assert isinstance(archive["command_line"], str)
-        assert isinstance(archive["duration"], float)
-        assert len(archive["id"]) == 64
-        assert "stats" in archive
-        checkts(archive["start"])
-        checkts(archive["end"])
-
-    def test_info_json_of_empty_archive(self):
-        """See https://github.com/borgbackup/borg/issues/6120"""
-        self.cmd(f"--repo={self.repository_location}", "rcreate", RK_ENCRYPTION)
-        info_repo = json.loads(self.cmd(f"--repo={self.repository_location}", "info", "--json", "--first=1"))
-        assert info_repo["archives"] == []
-        info_repo = json.loads(self.cmd(f"--repo={self.repository_location}", "info", "--json", "--last=1"))
-        assert info_repo["archives"] == []
-
-
-class RemoteArchiverTestCase(RemoteArchiverTestCaseBase, ArchiverTestCase):
-    """run the same tests, but with a remote repository"""
-
-
-@unittest.skipUnless("binary" in BORG_EXES, "no borg.exe available")
-class ArchiverTestCaseBinary(ArchiverTestCaseBinaryBase, ArchiverTestCase):
-    """runs the same tests, but via the borg binary"""
+from . import cmd, RK_ENCRYPTION, checkts, create_regular_file
+
+
+def pytest_generate_tests(metafunc):
+    # Generate tests for different scenarios: local repository, remote repository, and using the borg binary.
+    if "archivers" in metafunc.fixturenames:
+        metafunc.parametrize("archivers", ["archiver", "remote_archiver", "binary_archiver"])
+
+
+def test_info(archivers, request):
+    archiver = request.getfixturevalue(archivers)
+    repo_location, input_path = archiver.repository_location, archiver.input_path
+    create_regular_file(input_path, "file1", size=1024 * 80)
+    cmd(archiver, f"--repo={repo_location}", "rcreate", RK_ENCRYPTION)
+    cmd(archiver, f"--repo={repo_location}", "create", "test", "input")
+    info_archive = cmd(archiver, f"--repo={repo_location}", "info", "-a", "test")
+    assert "Archive name: test" + os.linesep in info_archive
+    info_archive = cmd(archiver, f"--repo={repo_location}", "info", "--first", "1")
+    assert "Archive name: test" + os.linesep in info_archive
+
+
+def test_info_json(archivers, request):
+    archiver = request.getfixturevalue(archivers)
+    repo_location, input_path = archiver.repository_location, archiver.input_path
+    create_regular_file(input_path, "file1", size=1024 * 80)
+    cmd(archiver, f"--repo={repo_location}", "rcreate", RK_ENCRYPTION)
+    cmd(archiver, f"--repo={repo_location}", "create", "test", "input")
+
+    info_archive = json.loads(cmd(archiver, f"--repo={repo_location}", "info", "-a", "test", "--json"))
+    archives = info_archive["archives"]
+    assert len(archives) == 1
+    archive = archives[0]
+    assert archive["name"] == "test"
+    assert isinstance(archive["command_line"], str)
+    assert isinstance(archive["duration"], float)
+    assert len(archive["id"]) == 64
+    assert "stats" in archive
+    checkts(archive["start"])
+    checkts(archive["end"])
+
+
+def test_info_json_of_empty_archive(archivers, request):
+    """See https://github.com/borgbackup/borg/issues/6120"""
+    archiver = request.getfixturevalue(archivers)
+    repo_location = archiver.repository_location
+    cmd(archiver, f"--repo={repo_location}", "rcreate", RK_ENCRYPTION)
+    info_repo = json.loads(cmd(archiver, f"--repo={repo_location}", "info", "--json", "--first=1"))
+    assert info_repo["archives"] == []
+    info_repo = json.loads(cmd(archiver, f"--repo={repo_location}", "info", "--json", "--last=1"))
+    assert info_repo["archives"] == []