Switch property to cached_property #73
Open
Azure Pipelines / wagtail-seo
failed
Sep 27, 2024 in 1m 47s
Build #20240927.5 had test failures
Details
- Failed: 2 (5.00%)
- Passed: 38 (95.00%)
- Other: 0 (0.00%)
- Total: 40
- 345 of 361 line covered (95.57%)
Annotations
Check failure on line 183 in Build log
azure-pipelines / wagtail-seo
Build log #L183
Bash exited with code '1'.
Check failure on line 190 in Build log
azure-pipelines / wagtail-seo
Build log #L190
Bash exited with code '1'.
Check failure on line 1 in test_struct_org
azure-pipelines / wagtail-seo
test_struct_org
AssertionError: False is not true : Couldn't find '<script type="application/ld+json">
{"@context": "http://schema.org", "@type": "Airline", "url": "http://localhost/fullseo/", "name": "Custom Org Name", "logo": {"@type": "ImageObject", "url": "http://localhost/media/images/test_pGZ0Znf.original_BcKrMFG.png"}, "image": ["http://localhost/media/images/test_mTcXSB0.2e16d0ba.fill-10000x10000_BPhbvZk.png", "http://localhost/media/images/test_mTcXSB0.2e16d0ba.fill-40000x30000_elKg4BN.png", "http://localhost/media/images/test_mTcXSB0.2e16d0ba.fill-16000x9000_fYU8l2N.png"], "telephone": "+1-555-867-5309", "address": {"@type": "PostalAddress", "streetAddress": "55 Public Square, Suite 1710", "addressLocality": "Cleveland", "addressRegion": "OH", "postalCode": "44113", "addressCountry": "US"}, "geo": {"@type": "GeoCoordinates", "latitude": 1.1, "longitude": 2.2}, "openingHoursSpecification": [{"@type": "OpeningHoursSpecification", "dayOfWeek": ["Monday", "Tuesday", "Wednesday"], "opens": "09:00:00", "closes": "17:00:00"}], "potentialAction": [{"@type": "OrderAction", "target": {"@type": "EntryPoint", "urlTemplate": "https://www.example.com/", "inLanguage": "en-US", "actionPlatform": ["http://schema.org/DesktopWebPlatform", "http://schema.org/IOSPlatform", "http://schema.org/AndroidPlatform"]}, "result": {"@type": "FoodEstablishmentReservation", "name": "Custom Result"}}], "json": true, "array": ["thing1", "thing2"]}
</script>' in response
Raw output
self = <home.tests.SeoTest testMethod=test_struct_org>
def test_struct_org(self):
"""
A page with SeoMixin should render correct structured data.
"""
page = self.page_fullseo
# Manually render the JSON and match against page HTML.
# Get images to compare against rendered content.
base_url = utils.get_absolute_media_url(page.get_site())
img1x1 = (
base_url
+ self.seo_set.struct_org_image.get_rendition(
"fill-10000x10000"
).url
)
img4x3 = (
base_url
+ self.seo_set.struct_org_image.get_rendition(
"fill-40000x30000"
).url
)
img16x9 = (
base_url
+ self.seo_set.struct_org_image.get_rendition("fill-16000x9000").url
)
expected_dict = {
"@context": "http://schema.org",
"@type": self.seo_set.struct_org_type,
"url": page.seo_canonical_url,
"name": page.seo_struct_org_name,
"logo": {
"@type": "ImageObject",
"url": page.seo_logo_url,
},
"image": [img1x1, img4x3, img16x9],
"telephone": self.seo_set.struct_org_phone,
"address": {
"@type": "PostalAddress",
"streetAddress": self.seo_set.struct_org_address_street,
"addressLocality": self.seo_set.struct_org_address_locality,
"addressRegion": self.seo_set.struct_org_address_region,
"postalCode": self.seo_set.struct_org_address_postal,
"addressCountry": self.seo_set.struct_org_address_country,
},
"geo": {
"@type": "GeoCoordinates",
"latitude": float(self.seo_set.struct_org_geo_lat),
"longitude": float(self.seo_set.struct_org_geo_lng),
},
"openingHoursSpecification": [],
"potentialAction": [],
}
for spec in self.seo_set.struct_org_hours:
expected_dict["openingHoursSpecification"].append(
spec.value.struct_dict
)
for action in self.seo_set.struct_org_actions:
expected_dict["potentialAction"].append(action.value.struct_dict)
expected_dict.update(json.loads(self.seo_set.struct_org_extra_json))
expected_json = json.dumps(expected_dict, cls=utils.StructDataEncoder)
# GET the page and check its JSON against expected JSON.
response = self.client.get(page.get_url())
self.assertEqual(response.status_code, 200)
self.maxDiff = None
print(response.content.decode("utf8"))
> self.assertInHTML(
f"""
<script type="application/ld+json">
{ expected_json }
</script>
""", # noqa
response.content.decode("utf8"),
)
testproject/home/tests.py:279:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/opt/hostedtoolcache/Python/3.8.18/x64/lib/python3.8/site-packages/django/test/testcases.py:993: in assertInHTML
self.assertTrue(
E AssertionError: False is not true : Couldn't find '<script type="application/ld+json">
E {"@context": "http://schema.org", "@type": "Airline", "url": "http://localhost/fullseo/", "name": "Custom Org Name", "logo": {"@type": "ImageObject", "url": "http://localhost/media/images/test_pGZ0Znf.original_BcKrMFG.png"}, "image": ["http://localhost/media/images/test_mTcXSB0.2e16d0ba.fill-10000x10000_BPhbvZk.png", "http://localhost/media/images/test_mTcXSB0.2e16d0ba.fill-40000x30000_elKg4BN.png", "http://localhost/media/images/test_mTcXSB0.2e16d0ba.fill-16000x9000_fYU8l2N.png"], "telephone": "+1-555-867-5309", "address": {"@type": "PostalAddress", "streetAddress": "55 Public Square, Suite 1710", "addressLocality": "Cleveland", "addressRegion": "OH", "postalCode":
Check failure on line 1 in test_struct_org
azure-pipelines / wagtail-seo
test_struct_org
AssertionError: False is not true : Couldn't find '<script type="application/ld+json">
{"@context": "http://schema.org", "@type": "Airline", "url": "http://localhost/fullseo/", "name": "Custom Org Name", "logo": {"@type": "ImageObject", "url": "http://localhost/media/images/test_qSYu45N.original_Of9bzIu.png"}, "image": ["http://localhost/media/images/test_7VBhMJr.2e16d0ba.fill-10000x10000_N7C3WT1.png", "http://localhost/media/images/test_7VBhMJr.2e16d0ba.fill-40000x30000_4xIaw0M.png", "http://localhost/media/images/test_7VBhMJr.2e16d0ba.fill-16000x9000_nqDGUMB.png"], "telephone": "+1-555-867-5309", "address": {"@type": "PostalAddress", "streetAddress": "55 Public Square, Suite 1710", "addressLocality": "Cleveland", "addressRegion": "OH", "postalCode": "44113", "addressCountry": "US"}, "geo": {"@type": "GeoCoordinates", "latitude": 1.1, "longitude": 2.2}, "openingHoursSpecification": [{"@type": "OpeningHoursSpecification", "dayOfWeek": ["Monday", "Tuesday", "Wednesday"], "opens": "09:00:00", "closes": "17:00:00"}], "potentialAction": [{"@type": "OrderAction", "target": {"@type": "EntryPoint", "urlTemplate": "https://www.example.com/", "inLanguage": "en-US", "actionPlatform": ["http://schema.org/DesktopWebPlatform", "http://schema.org/IOSPlatform", "http://schema.org/AndroidPlatform"]}, "result": {"@type": "FoodEstablishmentReservation", "name": "Custom Result"}}], "json": true, "array": ["thing1", "thing2"]}
</script>' in response
Raw output
self = <home.tests.SeoTest testMethod=test_struct_org>
def test_struct_org(self):
"""
A page with SeoMixin should render correct structured data.
"""
page = self.page_fullseo
# Manually render the JSON and match against page HTML.
# Get images to compare against rendered content.
base_url = utils.get_absolute_media_url(page.get_site())
img1x1 = (
base_url
+ self.seo_set.struct_org_image.get_rendition(
"fill-10000x10000"
).url
)
img4x3 = (
base_url
+ self.seo_set.struct_org_image.get_rendition(
"fill-40000x30000"
).url
)
img16x9 = (
base_url
+ self.seo_set.struct_org_image.get_rendition("fill-16000x9000").url
)
expected_dict = {
"@context": "http://schema.org",
"@type": self.seo_set.struct_org_type,
"url": page.seo_canonical_url,
"name": page.seo_struct_org_name,
"logo": {
"@type": "ImageObject",
"url": page.seo_logo_url,
},
"image": [img1x1, img4x3, img16x9],
"telephone": self.seo_set.struct_org_phone,
"address": {
"@type": "PostalAddress",
"streetAddress": self.seo_set.struct_org_address_street,
"addressLocality": self.seo_set.struct_org_address_locality,
"addressRegion": self.seo_set.struct_org_address_region,
"postalCode": self.seo_set.struct_org_address_postal,
"addressCountry": self.seo_set.struct_org_address_country,
},
"geo": {
"@type": "GeoCoordinates",
"latitude": float(self.seo_set.struct_org_geo_lat),
"longitude": float(self.seo_set.struct_org_geo_lng),
},
"openingHoursSpecification": [],
"potentialAction": [],
}
for spec in self.seo_set.struct_org_hours:
expected_dict["openingHoursSpecification"].append(
spec.value.struct_dict
)
for action in self.seo_set.struct_org_actions:
expected_dict["potentialAction"].append(action.value.struct_dict)
expected_dict.update(json.loads(self.seo_set.struct_org_extra_json))
expected_json = json.dumps(expected_dict, cls=utils.StructDataEncoder)
# GET the page and check its JSON against expected JSON.
response = self.client.get(page.get_url())
self.assertEqual(response.status_code, 200)
self.maxDiff = None
print(response.content.decode("utf8"))
> self.assertInHTML(
f"""
<script type="application/ld+json">
{ expected_json }
</script>
""", # noqa
response.content.decode("utf8"),
)
testproject/home/tests.py:279:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/django/test/testcases.py:1064: in assertInHTML
self.assertTrue(
E AssertionError: False is not true : Couldn't find '<script type="application/ld+json">
E {"@context": "http://schema.org", "@type": "Airline", "url": "http://localhost/fullseo/", "name": "Custom Org Name", "logo": {"@type": "ImageObject", "url": "http://localhost/media/images/test_qSYu45N.original_Of9bzIu.png"}, "image": ["http://localhost/media/images/test_7VBhMJr.2e16d0ba.fill-10000x10000_N7C3WT1.png", "http://localhost/media/images/test_7VBhMJr.2e16d0ba.fill-40000x30000_4xIaw0M.png", "http://localhost/media/images/test_7VBhMJr.2e16d0ba.fill-16000x9000_nqDGUMB.png"], "telephone&
Loading