|
|
@@ -476,7 +476,13 @@ class ObjectStore(object): |
|
|
|
return len(self._uuids) |
|
|
|
|
|
|
|
def __iter__(self): |
|
|
|
return iter(self._uuids.values()) |
|
|
|
seen = set() |
|
|
|
for i in self._uuids.values(): |
|
|
|
if i['uuid'] in seen: |
|
|
|
continue |
|
|
|
|
|
|
|
yield i |
|
|
|
seen.add(i['uuid']) |
|
|
|
|
|
|
|
def store(self, fname): |
|
|
|
'''Write out the objects in the store to the file named |
|
|
@@ -1331,6 +1337,10 @@ class _TestCases(unittest.TestCase): |
|
|
|
hostidpatch = mock.patch(__name__ + '.hostuuid') |
|
|
|
hostidpatch.start().return_value = uuid.uuid4() |
|
|
|
patches.append(hostidpatch) |
|
|
|
elif special == 'iter is unique': |
|
|
|
objst = ObjectStore.load(storefname) |
|
|
|
uniqobjs = len(set((x['uuid'] for x in objst))) |
|
|
|
self.assertEqual(len(list(objst)), uniqobjs) |
|
|
|
else: # pragma: no cover |
|
|
|
raise ValueError('unhandled special: %s' % repr(special)) |
|
|
|
|
|
|
|