From 3dc3ce5eb9d065c09a5ab1d9042bdcc7ac8a57ab Mon Sep 17 00:00:00 2001 From: Einar Forselv Date: Fri, 19 Apr 2019 00:13:51 +0200 Subject: [PATCH] More robust container comparator --- restic_volume_backup/containers.py | 6 ++++++ tests/tests.py | 1 + 2 files changed, 7 insertions(+) diff --git a/restic_volume_backup/containers.py b/restic_volume_backup/containers.py index d2f2fc9..e53ed1e 100644 --- a/restic_volume_backup/containers.py +++ b/restic_volume_backup/containers.py @@ -132,6 +132,12 @@ class Container: return value.split(',') def __eq__(self, other): + if other is None: + return False + + if not isinstance(other, Container): + return False + return self.id == other.id diff --git a/tests/tests.py b/tests/tests.py index 5531bef..37d999e 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -79,6 +79,7 @@ class ResticBackupTests(unittest.TestCase): self.assertEqual(len(result.containers), 3, msg="Three containers expected") self.assertNotEqual(result.this_container, None, msg="No backup container found") web_service = result.get_service('web') + self.assertNotEqual(web_service, None) self.assertEqual(len(web_service.filter_mounts()), 1) def test_include(self):