Update tests to handle that since ba8b8e0, we only delete images that we own

This commit is contained in:
Daniel Milnes 2026-04-26 17:00:45 +01:00
commit f7bcc53be9
Signed by untrusted user: thebeanogamer
GPG key ID: 1701097BBDD44D1B

View file

@ -17,6 +17,7 @@ from fedora_messaging import testing as fm_testing
from freezegun import freeze_time
from fedora_image_uploader import Uploader
from fedora_image_uploader.azure import OWNER
@pytest.mark.vcr
@ -181,7 +182,7 @@ def test_azure_old_excluded_images(azure_env_vars, azure_fm_conf):
azure_handler = consumer.handlers["azure"]
azure_handler.azure_compute_client = mock.Mock()
azure_handler.azure_blob_client = mock.Mock()
image_definition = GalleryImage(location="eastus")
image_definition = GalleryImage(location="eastus", tags={"owner": OWNER})
image_definition.name = "Fedora-40"
now = datetime.datetime.now(datetime.UTC)
image_versions = []
@ -190,7 +191,9 @@ def test_azure_old_excluded_images(azure_env_vars, azure_fm_conf):
exclude_from_latest=True, end_of_life_date=now + timedelta(days=7)
)
publish_profile.published_date = now + timedelta(seconds=v)
version = GalleryImageVersion(location="eastus", publishing_profile=publish_profile)
version = GalleryImageVersion(
location="eastus", publishing_profile=publish_profile, tags={"owner": OWNER}
)
version.name = f"40.1.{v}"
image_versions.append(version)
azure_handler.azure_compute_client.gallery_images.list_by_gallery.return_value = [
@ -218,7 +221,7 @@ def test_azure_end_of_life(azure_env_vars, azure_fm_conf):
azure_handler = consumer.handlers["azure"]
azure_handler.azure_compute_client = mock.Mock()
azure_handler.azure_blob_client = mock.Mock()
image_definition = GalleryImage(location="eastus")
image_definition = GalleryImage(location="eastus", tags={"owner": OWNER})
image_definition.name = "Fedora-40"
now = datetime.datetime.now(datetime.UTC)
image_versions = []
@ -227,7 +230,9 @@ def test_azure_end_of_life(azure_env_vars, azure_fm_conf):
exclude_from_latest=False, end_of_life_date=now + timedelta(days=v - 2)
)
publish_profile.published_date = now - timedelta(days=v)
version = GalleryImageVersion(location="eastus", publishing_profile=publish_profile)
version = GalleryImageVersion(
location="eastus", publishing_profile=publish_profile, tags={"owner": OWNER}
)
version.name = f"40.1.{v}"
image_versions.append(version)
azure_handler.azure_compute_client.gallery_images.list_by_gallery.return_value = [
@ -260,7 +265,7 @@ def test_azure_empty_definitions(azure_env_vars, azure_fm_conf):
azure_handler = consumer.handlers["azure"]
azure_handler.azure_compute_client = mock.Mock()
azure_handler.azure_blob_client = mock.Mock()
image_definition = GalleryImage(location="eastus")
image_definition = GalleryImage(location="eastus", tags={"owner": OWNER})
image_definition.name = "Fedora-40"
azure_handler.azure_compute_client.gallery_images.list_by_gallery.return_value = [
image_definition
@ -284,7 +289,7 @@ def test_azure_old_included_images(azure_env_vars, azure_fm_conf):
azure_handler = consumer.handlers["azure"]
azure_handler.azure_compute_client = mock.Mock()
azure_handler.azure_blob_client = mock.Mock()
image_definition = GalleryImage(location="eastus")
image_definition = GalleryImage(location="eastus", tags={"owner": OWNER})
image_definition.name = "Fedora-40"
now = datetime.datetime.now(datetime.UTC)
image_versions = []
@ -293,7 +298,9 @@ def test_azure_old_included_images(azure_env_vars, azure_fm_conf):
exclude_from_latest=False, end_of_life_date=now + timedelta(days=7)
)
publish_profile.published_date = now + timedelta(seconds=v)
version = GalleryImageVersion(location="eastus", publishing_profile=publish_profile)
version = GalleryImageVersion(
location="eastus", publishing_profile=publish_profile, tags={"owner": OWNER}
)
version.name = f"40.1.{v}"
image_versions.append(version)
azure_handler.azure_compute_client.gallery_images.list_by_gallery.return_value = [
@ -317,7 +324,7 @@ def test_azure_rolling_images(azure_env_vars, azure_fm_conf, rolling_image):
azure_handler = consumer.handlers["azure"]
azure_handler.azure_compute_client = mock.Mock()
azure_handler.azure_blob_client = mock.Mock()
image_definition = GalleryImage(location="eastus")
image_definition = GalleryImage(location="eastus", tags={"owner": OWNER})
image_definition.name = f"Fedora-{rolling_image}"
now = datetime.datetime.now(datetime.UTC)
image_versions = []
@ -326,7 +333,9 @@ def test_azure_rolling_images(azure_env_vars, azure_fm_conf, rolling_image):
exclude_from_latest=False, end_of_life_date=now + timedelta(days=7)
)
publish_profile.published_date = now + timedelta(seconds=v)
version = GalleryImageVersion(location="eastus", publishing_profile=publish_profile)
version = GalleryImageVersion(
location="eastus", publishing_profile=publish_profile, tags={"owner": OWNER}
)
version.name = f"41.1.{v}"
image_versions.append(version)
azure_handler.azure_compute_client.gallery_images.list_by_gallery.return_value = [