From 926fcdbdb9b94497b23b4ab96839fa06c9b6b4c4 Mon Sep 17 00:00:00 2001 From: Olivier Date: Tue, 20 Jul 2021 11:21:16 +0100 Subject: [PATCH] Fix tests by ignoring metadata (we skip applying it because no permissions) --- testsuite/datmantests/test_backup_and_extract.py | 5 +++-- testsuite/helpers/__init__.py | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/testsuite/datmantests/test_backup_and_extract.py b/testsuite/datmantests/test_backup_and_extract.py index 2deccc9..30ad51a 100644 --- a/testsuite/datmantests/test_backup_and_extract.py +++ b/testsuite/datmantests/test_backup_and_extract.py @@ -1,5 +1,4 @@ import subprocess -import time from pathlib import Path from random import Random from tempfile import TemporaryDirectory @@ -57,4 +56,6 @@ class TestBackupAndExtract(TestCase): key, value = next(iter(value.contents.items())) self.assertEqual(key, "srca") - self.assertEqual(value, later_expected_descriptor) + self.assertEqual( + value.ignore_metadata(), later_expected_descriptor.ignore_metadata() + ) diff --git a/testsuite/helpers/__init__.py b/testsuite/helpers/__init__.py index df91d48..1893274 100644 --- a/testsuite/helpers/__init__.py +++ b/testsuite/helpers/__init__.py @@ -26,6 +26,11 @@ class FileDescriptor: owner: int group: int + def ignore_metadata(self) -> "FileDescriptor": + return FileDescriptor( + sha256_sum=self.sha256_sum, mtime_ms=0, permissions=0, owner=0, group=0 + ) + @attr.s(auto_attribs=True, frozen=True) class DirectoryDescriptor: @@ -35,6 +40,15 @@ class DirectoryDescriptor: owner: int group: int + def ignore_metadata(self) -> "DirectoryDescriptor": + return DirectoryDescriptor( + immutabledict({k: v.ignore_metadata() for k, v in self.contents.items()}), + mtime_ms=0, + permissions=0, + owner=0, + group=0, + ) + def generate_random_file(rng: Random, path: Path) -> FileDescriptor: """