Example #1
0
 def test_version_uid_to_key(self):
     for i in range(100):
         version_uid = VersionUid('v{}'.format(
             random.randint(1,
                            pow(2, 32) - 1)))
         key = version_uid.storage_object_to_path()
         version_uid_2 = VersionUid.storage_path_to_object(key)
         self.assertEqual(version_uid, version_uid_2)
Example #2
0
 def list_versions(self) -> Iterable[VersionUid]:
     keys = self._list_objects(VersionUid.storage_prefix())
     for key in keys:
         assert isinstance(key, str)
         if key.endswith(self._META_SUFFIX):
             continue
         try:
             yield cast(VersionUid, VersionUid.storage_path_to_object(key))
         except (RuntimeError, ValueError):
             # Ignore any keys which don't match our pattern to account for stray objects/files
             pass
Example #3
0
 def list_versions(self) -> List[VersionUid]:
     keys = self._list_objects(VersionUid.storage_prefix())
     version_uids: List[VersionUid] = []
     for key in keys:
         if key.endswith(self._META_SUFFIX):
             continue
         try:
             version_uids.append(
                 cast(VersionUid, VersionUid.storage_path_to_object(key)))
         except (RuntimeError, ValueError):
             # Ignore any keys which don't match our pattern to account for stray objects/files
             pass
     return version_uids