diff --git a/glance/domain/__init__.py b/glance/domain/__init__.py index a77bf020c2..238ca1a69e 100644 --- a/glance/domain/__init__.py +++ b/glance/domain/__init__.py @@ -295,6 +295,9 @@ class ExtraProperties(collections.MutableMapping, dict): else: return False + def __ne__(self, other): + return not self.__eq__(other) + def __len__(self): return dict(self).__len__() diff --git a/glance/location.py b/glance/location.py index 2739a1caa5..5a8f5cbd05 100644 --- a/glance/location.py +++ b/glance/location.py @@ -303,6 +303,9 @@ class StoreLocations(collections.MutableSequence): def __eq__(self, other): return self.value == self.__cast(other) + def __ne__(self, other): + return not self.__eq__(other) + def __iter__(self): return iter(self.value) diff --git a/glance/quota/__init__.py b/glance/quota/__init__.py index ee3047dc2f..ee16a0c136 100644 --- a/glance/quota/__init__.py +++ b/glance/quota/__init__.py @@ -150,6 +150,9 @@ class QuotaImageTagsProxy(object): def __eq__(self, other): return self.tags == other + def __ne__(self, other): + return not self.__eq__(other) + def __iter__(self, *args, **kwargs): return self.tags.__iter__(*args, **kwargs) @@ -214,6 +217,9 @@ class QuotaImageLocationsProxy(object): def __eq__(self, other): return self.locations == other + def __ne__(self, other): + return not self.__eq__(other) + def __getitem__(self, *args, **kwargs): return self.locations.__getitem__(*args, **kwargs) diff --git a/glance/tests/unit/test_domain.py b/glance/tests/unit/test_domain.py index 95e0bf1649..5328ec3049 100644 --- a/glance/tests/unit/test_domain.py +++ b/glance/tests/unit/test_domain.py @@ -298,7 +298,7 @@ class TestExtraProperties(test_utils.BaseTestCase): a_dict = {'foo': 'bar', 'snitch': 'golden'} extra_properties = domain.ExtraProperties(a_dict) ref_extra_properties = {'boo': 'far', 'gnitch': 'solden'} - self.assertFalse(extra_properties.__eq__(ref_extra_properties)) + self.assertNotEqual(ref_extra_properties, extra_properties) def test_eq_with_unequal_ExtraProperties_object(self): a_dict = {'foo': 'bar', 'snitch': 'golden'} @@ -306,13 +306,13 @@ class TestExtraProperties(test_utils.BaseTestCase): ref_extra_properties = domain.ExtraProperties() ref_extra_properties['gnitch'] = 'solden' ref_extra_properties['boo'] = 'far' - self.assertFalse(extra_properties.__eq__(ref_extra_properties)) + self.assertNotEqual(ref_extra_properties, extra_properties) def test_eq_with_incompatible_object(self): a_dict = {'foo': 'bar', 'snitch': 'golden'} extra_properties = domain.ExtraProperties(a_dict) random_list = ['foo', 'bar'] - self.assertFalse(extra_properties.__eq__(random_list)) + self.assertNotEqual(random_list, extra_properties) class TestTaskFactory(test_utils.BaseTestCase): diff --git a/glance/tests/unit/test_quota.py b/glance/tests/unit/test_quota.py index 0dfadec87a..22bd395613 100644 --- a/glance/tests/unit/test_quota.py +++ b/glance/tests/unit/test_quota.py @@ -572,6 +572,10 @@ class TestQuotaImageTagsProxy(test_utils.BaseTestCase): proxy = glance.quota.QuotaImageTagsProxy(set([])) self.assertEqual(set([]), proxy) + def test_not_equals(self): + proxy = glance.quota.QuotaImageTagsProxy(set([])) + self.assertNotEqual('foo', proxy) + def test_contains(self): proxy = glance.quota.QuotaImageTagsProxy(set(['foo'])) self.assertIn('foo', proxy)