def test_get_manifest(archive_changeset: ArchiveChangeset, image_name: ImageName): """Test manifest retrieval.""" manifest = archive_changeset.get_manifest(image_name) if image_name.resolve_digest(): assert manifest.get_config_digest() == image_name.resolve_digest() if image_name.tag: assert ArchiveChangeset.get_repository_tag( image_name) in manifest.get_tags()
def test_remove_tags(archive_changeset: ArchiveChangeset): """Test repository tag removal""" image_name = ImageName( "base", digest=FormattedSHA256( "adecf4209bb9dd67d96393774cbd7f8bd2bad3596da42cde33daa0c41b14ac62" ), tag="7.2", ) tag = ArchiveChangeset.get_repository_tag(image_name) manifest = archive_changeset.get_manifest(image_name) assert tag in manifest.get_tags() archive_changeset.remove_tags(["dummy"]) manifest = archive_changeset.get_manifest(image_name) assert tag in manifest.get_tags() archive_changeset.remove_tags([tag]) manifest = archive_changeset.get_manifest(image_name) assert not manifest.get_tags()
def test_append_manifest( archive_changeset: ArchiveChangeset, formattedsha256: FormattedSHA256, tags, ): """Test appending manifests.""" assert len(archive_changeset.get_manifests()) == 2 # Append a new manifest ... manifest = ArchiveManifest(b"{}") manifest.set_config_digest(formattedsha256) manifest.set_tags(tags) archive_changeset.append_manifest(manifest) assert len(archive_changeset.get_manifests()) == 3 # Append it again ... archive_changeset.append_manifest(manifest) assert len(archive_changeset.get_manifests()) == 3
def test_normalize_tags(expected: str, tag: str): """Test repository tag normalization.""" assert ArchiveChangeset.normalize_tags([tag]) == [expected]
def archive_changeset(archive_changeset_raw: bytes) -> ArchiveChangeset: """Provides an ArchiveChangeset instance for the sample archive manifest.""" # Do not use caching; get a new instance for each test return ArchiveChangeset(archive_changeset_raw)
def test_remove_manifest(archive_changeset: ArchiveChangeset, image_name: ImageName): """Test manifest removal.""" assert len(archive_changeset.get_manifests()) == 2 archive_changeset.remove_manifest(image_name.resolve_digest()) assert len(archive_changeset.get_manifests()) == 1
def test_get_manifests(archive_changeset: ArchiveChangeset): """Test retrieving all manifests.""" assert len(archive_changeset.get_manifests()) == 2