Merge "occi: add equality operator to resources"
This commit is contained in:
commit
783d118e56
|
@ -45,6 +45,10 @@ class Resource(entity.Entity):
|
|||
"occi.core.summary", summary)
|
||||
self._links = []
|
||||
|
||||
def __eq__(self, other):
|
||||
return all([self.attributes[i].value == other.attributes[i].value
|
||||
for i in self.attributes])
|
||||
|
||||
@property
|
||||
def links(self):
|
||||
return self._links
|
||||
|
|
|
@ -257,6 +257,12 @@ class TestCoreOCCIResource(base.TestCase):
|
|||
r.summary = "bazonk"
|
||||
self.assertEqual("bazonk", r.summary)
|
||||
|
||||
def test_resources_equal(self):
|
||||
id = uuid.uuid4().hex
|
||||
r = resource.Resource("bar", [], summary="baz", id=id)
|
||||
s = resource.Resource("bar", [], summary="baz", id=id)
|
||||
self.assertEqual(r, s)
|
||||
|
||||
def test_valid_link(self):
|
||||
r1 = resource.Resource(None, [])
|
||||
r2 = resource.Resource(None, [])
|
||||
|
|
Loading…
Reference in New Issue