|
|
|
@ -81,7 +81,7 @@ def test_setup(client, live_server, measure_memory_usage):
|
|
|
|
|
|
|
|
|
|
# actually only really used by the distll.io importer, but could be handy too
|
|
|
|
|
def test_check_ldjson_price_autodetect(client, live_server, measure_memory_usage):
|
|
|
|
|
|
|
|
|
|
#live_server_setup(live_server)
|
|
|
|
|
set_response_with_ldjson()
|
|
|
|
|
|
|
|
|
|
# Add our URL to the import page
|
|
|
|
@ -160,7 +160,7 @@ def _test_runner_check_bad_format_ignored(live_server, client, has_ldjson_price_
|
|
|
|
|
|
|
|
|
|
for k,v in client.application.config.get('DATASTORE').data['watching'].items():
|
|
|
|
|
assert v.get('last_error') == False
|
|
|
|
|
assert v.get('has_ldjson_price_data') == has_ldjson_price_data
|
|
|
|
|
assert v.get('has_ldjson_price_data') == has_ldjson_price_data, f"Detected LDJSON data? should be {has_ldjson_price_data}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
##########################################################################################
|
|
|
|
@ -201,35 +201,38 @@ def test_bad_ldjson_is_correctly_ignored(client, live_server, measure_memory_usa
|
|
|
|
|
f.write(test_return_data)
|
|
|
|
|
|
|
|
|
|
_test_runner_check_bad_format_ignored(live_server=live_server, client=client, has_ldjson_price_data=True)
|
|
|
|
|
test_return_data = """
|
|
|
|
|
<html>
|
|
|
|
|
<head>
|
|
|
|
|
<script type="application/ld+json">
|
|
|
|
|
{
|
|
|
|
|
"@context": "http://schema.org",
|
|
|
|
|
"@type": ["Product", "SubType"],
|
|
|
|
|
"name": "My test product",
|
|
|
|
|
"description": "",
|
|
|
|
|
"BrokenOffers": {
|
|
|
|
|
"@type": "Offer",
|
|
|
|
|
"offeredBy": {
|
|
|
|
|
"@type": "Organization",
|
|
|
|
|
"name":"Person",
|
|
|
|
|
"telephone":"+1 999 999 999"
|
|
|
|
|
},
|
|
|
|
|
"price": "1",
|
|
|
|
|
"priceCurrency": "EUR",
|
|
|
|
|
"url": "/some/url"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
</head>
|
|
|
|
|
<body>
|
|
|
|
|
<div class="yes">Some extra stuff</div>
|
|
|
|
|
</body></html>
|
|
|
|
|
"""
|
|
|
|
|
with open("test-datastore/endpoint-content.txt", "w") as f:
|
|
|
|
|
f.write(test_return_data)
|
|
|
|
|
|
|
|
|
|
_test_runner_check_bad_format_ignored(live_server=live_server, client=client, has_ldjson_price_data=False)
|
|
|
|
|
# This is OK that it offers a suggestion in this case, the processor will let them know more about something wrong
|
|
|
|
|
|
|
|
|
|
# test_return_data = """
|
|
|
|
|
# <html>
|
|
|
|
|
# <head>
|
|
|
|
|
# <script type="application/ld+json">
|
|
|
|
|
# {
|
|
|
|
|
# "@context": "http://schema.org",
|
|
|
|
|
# "@type": ["Product", "SubType"],
|
|
|
|
|
# "name": "My test product",
|
|
|
|
|
# "description": "",
|
|
|
|
|
# "BrokenOffers": {
|
|
|
|
|
# "@type": "Offer",
|
|
|
|
|
# "offeredBy": {
|
|
|
|
|
# "@type": "Organization",
|
|
|
|
|
# "name":"Person",
|
|
|
|
|
# "telephone":"+1 999 999 999"
|
|
|
|
|
# },
|
|
|
|
|
# "price": "1",
|
|
|
|
|
# "priceCurrency": "EUR",
|
|
|
|
|
# "url": "/some/url"
|
|
|
|
|
# }
|
|
|
|
|
# }
|
|
|
|
|
# </script>
|
|
|
|
|
# </head>
|
|
|
|
|
# <body>
|
|
|
|
|
# <div class="yes">Some extra stuff</div>
|
|
|
|
|
# </body></html>
|
|
|
|
|
# """
|
|
|
|
|
# with open("test-datastore/endpoint-content.txt", "w") as f:
|
|
|
|
|
# f.write(test_return_data)
|
|
|
|
|
#
|
|
|
|
|
# _test_runner_check_bad_format_ignored(live_server=live_server, client=client, has_ldjson_price_data=False)
|
|
|
|
|
|
|
|
|
|