Refactor ImageObject schema to remove license metadata

This commit is contained in:
Joakim Hellsén 2026-03-17 16:24:28 +01:00
commit f04d88e8fd
Signed by: Joakim Hellsén
SSH key fingerprint: SHA256:/9h/CsExpFp+PRhsfA0xznFx2CGfTT5R/kpuFfUgEQk
2 changed files with 4 additions and 23 deletions

View file

@ -1730,7 +1730,7 @@ class TestImageObjectStructuredData:
org: Organization, org: Organization,
monkeypatch: pytest.MonkeyPatch, monkeypatch: pytest.MonkeyPatch,
) -> None: ) -> None:
"""VideoGame ImageObject should carry attribution and license metadata.""" """VideoGame ImageObject should carry attribution metadata."""
url: str = reverse("twitch:game_detail", args=[game.twitch_id]) url: str = reverse("twitch:game_detail", args=[game.twitch_id])
response: _MonkeyPatchedWSGIResponse = client.get(url) response: _MonkeyPatchedWSGIResponse = client.get(url)
@ -1743,14 +1743,6 @@ class TestImageObjectStructuredData:
"name": org.name, "name": org.name,
"url": f"http://testserver{reverse('twitch:organization_detail', args=[org.twitch_id])}", "url": f"http://testserver{reverse('twitch:organization_detail', args=[org.twitch_id])}",
} }
assert (
img["license"]
== f"http://testserver{reverse('twitch:organization_detail', args=[org.twitch_id])}"
)
assert (
img["acquireLicensePage"]
== f"http://testserver{reverse('twitch:organization_detail', args=[org.twitch_id])}"
)
def test_game_schema_no_image_when_no_box_art( def test_game_schema_no_image_when_no_box_art(
self, self,
@ -1850,7 +1842,7 @@ class TestImageObjectStructuredData:
org: Organization, org: Organization,
monkeypatch: pytest.MonkeyPatch, monkeypatch: pytest.MonkeyPatch,
) -> None: ) -> None:
"""Event ImageObject should carry attribution and license metadata.""" """Event ImageObject should carry attribution metadata."""
url: str = reverse("twitch:campaign_detail", args=[campaign.twitch_id]) url: str = reverse("twitch:campaign_detail", args=[campaign.twitch_id])
response: _MonkeyPatchedWSGIResponse = client.get(url) response: _MonkeyPatchedWSGIResponse = client.get(url)
@ -1863,14 +1855,6 @@ class TestImageObjectStructuredData:
"name": org.name, "name": org.name,
"url": f"http://testserver{reverse('twitch:organization_detail', args=[org.twitch_id])}", "url": f"http://testserver{reverse('twitch:organization_detail', args=[org.twitch_id])}",
} }
assert (
img["license"]
== f"http://testserver{reverse('twitch:organization_detail', args=[org.twitch_id])}"
)
assert (
img["acquireLicensePage"]
== f"http://testserver{reverse('twitch:organization_detail', args=[org.twitch_id])}"
)
def test_campaign_schema_no_image_when_no_image_url( def test_campaign_schema_no_image_when_no_image_url(
self, self,
@ -1947,8 +1931,6 @@ class TestImageObjectStructuredData:
"name": "Twitch", "name": "Twitch",
"url": "https://www.twitch.tv/", "url": "https://www.twitch.tv/",
} }
assert schema["image"]["license"] == "https://www.twitch.tv/"
assert schema["image"]["acquireLicensePage"] == "https://www.twitch.tv/"
assert "organizer" not in schema assert "organizer" not in schema
# --- _pick_owner / Twitch Gaming skipping --- # --- _pick_owner / Twitch Gaming skipping ---

View file

@ -79,7 +79,7 @@ def _build_image_object(
*, *,
copyright_notice: str | None = None, copyright_notice: str | None = None,
) -> dict[str, Any]: ) -> dict[str, Any]:
"""Build a Schema.org ImageObject with attribution and license metadata. """Build a Schema.org ImageObject with attribution metadata.
Args: Args:
request: The HTTP request used for absolute URL building. request: The HTTP request used for absolute URL building.
@ -96,14 +96,13 @@ def _build_image_object(
"name": creator_name, "name": creator_name,
"url": creator_url, "url": creator_url,
} }
return { return {
"@type": "ImageObject", "@type": "ImageObject",
"contentUrl": request.build_absolute_uri(image_url), "contentUrl": request.build_absolute_uri(image_url),
"creditText": creator_name, "creditText": creator_name,
"copyrightNotice": copyright_notice or creator_name, "copyrightNotice": copyright_notice or creator_name,
"creator": creator, "creator": creator,
"license": creator_url,
"acquireLicensePage": creator_url,
} }