def make_content(self, hash=None, crc32=None, size=None,
                  deflated_size=None, storage_key=None, magic_hash=None):
     """Create content for a file node."""
     content = ContentBlob()
     content.hash = hash or get_fake_hash()
     content.magic_hash = magic_hash or get_fake_hash()
     content.crc32 = crc32 or self.get_unique_integer()
     content.size = size or self.get_unique_integer()
     content.deflated_size = deflated_size or self.get_unique_integer()
     content.status = STATUS_LIVE
     content.storage_key = storage_key or uuid.uuid4()
     self.store.add(content)
     return content
Beispiel #2
0
def get_test_contentblob(content=None):
    """Get a content blob"""
    if content:
        content = content.encode("utf-8")
    cb = ContentBlob()
    cb.hash = get_fake_hash(content)
    cb.crc32 = 1023
    cb.size = 1024
    cb.deflated_size = 10000
    cb.storage_key = uuid.uuid4()
    cb.content = content
    cb.status = STATUS_LIVE
    return cb