import hashlib from playhouse.test_utils import assert_query_count from data import model from data.database import ImageStorageLocation from endpoints.v2.models_pre_oci import data_model from test.fixtures import * def test_get_blob_path(initialized_db): # Add a blob. digest = 'sha256:' + hashlib.sha256("a").hexdigest() location = ImageStorageLocation.get(name='local_us') db_blob = model.blob.store_blob_record_and_temp_link('devtable', 'simple', digest, location, 1, 10000000) with assert_query_count(1): blob = data_model.get_blob_by_digest('devtable', 'simple', digest) assert blob.uuid == db_blob.uuid # The blob tuple should have everything get_blob_path needs, so there should be no queries. with assert_query_count(0): assert data_model.get_blob_path(blob) assert data_model.get_blob_path(blob) == model.storage.get_layer_path(db_blob)