51e67ab7f5
This will be supported by caching, hopefully removing the need to hit the database when the blob object is cached
25 lines
937 B
Python
25 lines
937 B
Python
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)
|