def test_resolv_image(image_name: ImageName): """Test image resolution.""" assert image_name.resolve_image() == "namespace/image" image_name = ImageName(image_name.endpoint, "image", image_name.tag) assert image_name.resolve_image() == "{0}/{1}".format( ImageName.DEFAULT_REGISTRY_NAMESPACE, image_name.image )
def test_str(): """Test __str__ pass-through for different variants.""" for endpoint in ["endpoint.io", "endpoint:port", None]: for image in ["image", "namespace/image"]: for tag in ["tag", None]: image_name = ImageName(endpoint, image, tag) string = str(image_name) assert image in string if endpoint: assert endpoint in string if tag: assert tag in string assert "None" not in string
def test_archive_append_config( archive_manifest: ArchiveManifest, sha256_archive_layer: str, formattedsha256: FormattedSHA256, repotag, ): """Test appending configurations.""" layers = [formattedsha256] archive_manifest.append_config(formattedsha256, layers, repotag) image_name = ImageName(None, formattedsha256.sha256) config = archive_manifest.get_config(image_name) assert config["Config"] == "{0}.json".format(formattedsha256.sha256) assert config["Layers"] == [sha256_archive_layer] assert config.get("RepoTags", None) == repotag
def test_init(): """Test that image name can be instantiated.""" assert ImageName("endpoint:port", "namespace/image", "tag")
def test_resolv_endpoint(image_name: ImageName): """Test endpoint resolution.""" assert image_name.resolve_endpoint() == "endpoint:port" image_name = ImageName(None, image_name.image, image_name.tag) assert image_name.resolve_endpoint() == ImageName.DEFAULT_REGISTRY_ENDPOINT
def test_resolv_tag(image_name: ImageName): """Test tag resolution.""" assert image_name.resolve_tag() == "tag" image_name = ImageName(image_name.endpoint, image_name.image, None) assert image_name.resolve_tag() == ImageName.DEFAULT_REGISTRY_TAG