This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/data/model/test/test_model_blob.py
2018-07-13 13:19:46 +03:00

32 lines
1.3 KiB
Python

from data import model, database
from test.fixtures import *
ADMIN_ACCESS_USER = 'devtable'
REPO = 'simple'
def test_store_blob(initialized_db):
location = database.ImageStorageLocation.select().get()
# Create a new blob at a unique digest.
digest = 'somecooldigest'
blob_storage = model.blob.store_blob_record_and_temp_link(ADMIN_ACCESS_USER, REPO, digest,
location, 1024, 0, 5000)
assert blob_storage.content_checksum == digest
assert blob_storage.image_size == 1024
assert blob_storage.uncompressed_size == 5000
# Link to the same digest.
blob_storage2 = model.blob.store_blob_record_and_temp_link(ADMIN_ACCESS_USER, REPO, digest,
location, 2048, 0, 6000)
assert blob_storage2.id == blob_storage.id
assert blob_storage2.image_size == 2048
assert blob_storage2.uncompressed_size == 6000
# Add a new digest, ensure it has a new record.
otherdigest = 'anotherdigest'
blob_storage3 = model.blob.store_blob_record_and_temp_link(ADMIN_ACCESS_USER, REPO, otherdigest,
location, 1234, 0, 5678)
assert blob_storage3.id != blob_storage.id
assert blob_storage3.image_size == 1234
assert blob_storage3.uncompressed_size == 5678