瀏覽代碼

move item related test to item testing module

Thomas Waldmann 2 年之前
父節點
當前提交
4a720e9abd
共有 2 個文件被更改,包括 20 次插入20 次删除
  1. 1 19
      src/borg/testsuite/archiver/__init__.py
  2. 19 1
      src/borg/testsuite/item.py

+ 1 - 19
src/borg/testsuite/archiver/__init__.py

@@ -35,7 +35,7 @@ from ...helpers import msgpack
 from ...helpers import flags_noatime, flags_normal
 from ...manifest import Manifest, MandatoryFeatureUnsupported
 from ...patterns import IECommand, PatternMatcher, parse_pattern
-from ...item import Item, chunks_contents_equal
+from ...item import Item
 from ...logger import setup_logging
 from ...remote import RemoteRepository, PathNotAllowed
 from ...repository import Repository
@@ -2187,24 +2187,6 @@ class ArchiverCorruptionTestCase(ArchiverTestCaseBase):
         assert "Cache integrity data not available: old Borg version modified the cache." in out
 
 
-def test_chunk_content_equal():
-    def ccc(a, b):
-        chunks_a = [data for data in a]
-        chunks_b = [data for data in b]
-        compare1 = chunks_contents_equal(iter(chunks_a), iter(chunks_b))
-        compare2 = chunks_contents_equal(iter(chunks_b), iter(chunks_a))
-        assert compare1 == compare2
-        return compare1
-
-    assert ccc([b"1234", b"567A", b"bC"], [b"1", b"23", b"4567A", b"b", b"C"])
-    # one iterator exhausted before the other
-    assert not ccc([b"12345"], [b"1234", b"56"])
-    # content mismatch
-    assert not ccc([b"1234", b"65"], [b"1234", b"56"])
-    # first is the prefix of second
-    assert not ccc([b"1234", b"56"], [b"1234", b"565"])
-
-
 class TestBuildFilter:
     def test_basic(self):
         matcher = PatternMatcher()

+ 19 - 1
src/borg/testsuite/item.py

@@ -1,7 +1,7 @@
 import pytest
 
 from ..cache import ChunkListEntry
-from ..item import Item
+from ..item import Item, chunks_contents_equal
 from ..helpers import StableDict
 from ..helpers.msgpack import Timestamp
 
@@ -156,3 +156,21 @@ def test_item_file_size_no_chunks():
 def test_item_optr():
     item = Item()
     assert Item.from_optr(item.to_optr()) is item
+
+
+def test_chunk_content_equal():
+    def ccc(a, b):
+        chunks_a = [data for data in a]
+        chunks_b = [data for data in b]
+        compare1 = chunks_contents_equal(iter(chunks_a), iter(chunks_b))
+        compare2 = chunks_contents_equal(iter(chunks_b), iter(chunks_a))
+        assert compare1 == compare2
+        return compare1
+
+    assert ccc([b"1234", b"567A", b"bC"], [b"1", b"23", b"4567A", b"b", b"C"])
+    # one iterator exhausted before the other
+    assert not ccc([b"12345"], [b"1234", b"56"])
+    # content mismatch
+    assert not ccc([b"1234", b"65"], [b"1234", b"56"])
+    # first is the prefix of second
+    assert not ccc([b"1234", b"56"], [b"1234", b"565"])