Convert V2's manifest endpoints to use the new data model interface
This commit is contained in:
parent
a172de4fdc
commit
6b5064aba4
10 changed files with 197 additions and 200 deletions
|
@ -8,6 +8,7 @@ import pytest
|
|||
from mock import patch
|
||||
from playhouse.test_utils import assert_query_count
|
||||
|
||||
from app import docker_v2_signing_key
|
||||
from data import model
|
||||
from data.database import (TagManifestLabelMap, TagManifestToManifest, Manifest, ManifestBlob,
|
||||
ManifestLegacyImage, ManifestLabel, TagManifest, RepositoryTag, Image,
|
||||
|
@ -16,6 +17,7 @@ from data.database import (TagManifestLabelMap, TagManifestToManifest, Manifest,
|
|||
from data.cache.impl import InMemoryDataModelCache
|
||||
from data.registry_model.registry_pre_oci_model import PreOCIModel
|
||||
from data.registry_model.datatypes import RepositoryReference
|
||||
from image.docker.schema1 import DockerSchema1ManifestBuilder
|
||||
|
||||
from test.fixtures import *
|
||||
|
||||
|
@ -235,6 +237,10 @@ def test_repository_tag_history(pre_oci_model):
|
|||
assert not has_more
|
||||
assert len(history) == 2
|
||||
|
||||
# Ensure the latest tag is marked expired, since there is an expired one.
|
||||
with assert_query_count(1):
|
||||
assert pre_oci_model.has_expired_tag(repository_ref, 'latest')
|
||||
|
||||
|
||||
@pytest.mark.parametrize('repo_namespace, repo_name', [
|
||||
('devtable', 'simple'),
|
||||
|
@ -685,3 +691,27 @@ def test_get_cached_repo_blob(pre_oci_model):
|
|||
# does not contain the blob.
|
||||
with pytest.raises(SomeException):
|
||||
pre_oci_model.get_cached_repo_blob(model_cache, 'devtable', 'simple', 'some other digest')
|
||||
|
||||
|
||||
def test_create_manifest_and_retarget_tag(pre_oci_model):
|
||||
repository_ref = pre_oci_model.lookup_repository('devtable', 'simple')
|
||||
latest_tag = pre_oci_model.get_repo_tag(repository_ref, 'latest', include_legacy_image=True)
|
||||
manifest = pre_oci_model.get_manifest_for_tag(latest_tag).get_parsed_manifest()
|
||||
|
||||
builder = DockerSchema1ManifestBuilder('devtable', 'simple', 'anothertag')
|
||||
builder.add_layer(manifest.blob_digests[0],
|
||||
'{"id": "%s"}' % latest_tag.legacy_image.docker_image_id)
|
||||
sample_manifest = builder.build(docker_v2_signing_key)
|
||||
assert sample_manifest is not None
|
||||
|
||||
another_manifest, tag = pre_oci_model.create_manifest_and_retarget_tag(repository_ref,
|
||||
sample_manifest,
|
||||
'anothertag')
|
||||
assert another_manifest is not None
|
||||
assert tag is not None
|
||||
|
||||
assert tag.name == 'anothertag'
|
||||
assert another_manifest.get_parsed_manifest().manifest_dict == sample_manifest.manifest_dict
|
||||
|
||||
layers = pre_oci_model.list_manifest_layers(another_manifest)
|
||||
assert len(layers) == 1
|
||||
|
|
Reference in a new issue