More robust container comparator

This commit is contained in:
Einar Forselv 2019-04-19 00:13:51 +02:00
parent ba642eeb4b
commit 3dc3ce5eb9
2 changed files with 7 additions and 0 deletions

View File

@ -132,6 +132,12 @@ class Container:
return value.split(',') return value.split(',')
def __eq__(self, other): def __eq__(self, other):
if other is None:
return False
if not isinstance(other, Container):
return False
return self.id == other.id return self.id == other.id

View File

@ -79,6 +79,7 @@ class ResticBackupTests(unittest.TestCase):
self.assertEqual(len(result.containers), 3, msg="Three containers expected") self.assertEqual(len(result.containers), 3, msg="Three containers expected")
self.assertNotEqual(result.this_container, None, msg="No backup container found") self.assertNotEqual(result.this_container, None, msg="No backup container found")
web_service = result.get_service('web') web_service = result.get_service('web')
self.assertNotEqual(web_service, None)
self.assertEqual(len(web_service.filter_mounts()), 1) self.assertEqual(len(web_service.filter_mounts()), 1)
def test_include(self): def test_include(self):