Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Drop unused SEO functions (#17606)
Marcin Gębalae225aff7d3fd
diff --git a/saleor/seo/schema/__init__.py b/saleor/seo/schema/__init__.pydeleted file mode 100644index e69de29bb2..0000000000diff --git a/saleor/seo/schema/email.py b/saleor/seo/schema/email.pydeleted file mode 100644index af6627790a..0000000000--- a/saleor/seo/schema/email.py+++ /dev/null@@ -1,69 +0,0 @@-import json-from typing import TYPE_CHECKING--from django.contrib.sites.models import Site--from ...core.utils import build_absolute_uri-from ...core.utils.json_serializer import HTMLSafeJSON--if TYPE_CHECKING:- from ...order.models import Order, OrderLine---def get_organization():- site = Site.objects.get_current()- return {"@type": "Organization", "name": site.name}---def get_product_data(line: "OrderLine", organization: dict) -> dict:- gross_product_price = line.total_price.gross- line_name = str(line)- if line.translated_product_name:- line_name = (- f"{line.translated_product_name} ({line.translated_variant_name})"- if line.translated_variant_name- else line.translated_product_name- )- product_data = {- "@type": "Offer",- "itemOffered": {- "@type": "Product",- "name": line_name,- "sku": line.product_sku or line.product_variant_id,- },- "price": gross_product_price.amount,- "priceCurrency": gross_product_price.currency,- "eligibleQuantity": {"@type": "QuantitativeValue", "value": line.quantity},- "seller": organization,- }-- if not line.variant:- return {}-- product = line.variant.product- product_image = product.get_first_image()- if product_image:- image = product_image.image- product_data["itemOffered"]["image"] = build_absolute_uri(location=image.url)- return product_data---def get_order_confirmation_markup(order: "Order") -> str:- """Generate schema.org markup for order confirmation e-mail message."""- organization = get_organization()- data = {- "@context": "http://schema.org",- "@type": "Order",- "merchant": organization,- "orderNumber": order.pk,- "priceCurrency": order.total.gross.currency,- "price": order.total.gross.amount,- "acceptedOffer": [],- "orderStatus": "http://schema.org/OrderProcessing",- "orderDate": order.created_at,- }-- for line in order.lines.all():- product_data = get_product_data(line=line, organization=organization)- data["acceptedOffer"].append(product_data)- return json.dumps(data, cls=HTMLSafeJSON)diff --git a/saleor/seo/tests/__init__.py b/saleor/seo/tests/__init__.pydeleted file mode 100644index e69de29bb2..0000000000diff --git a/saleor/seo/tests/test_seo_schema.py b/saleor/seo/tests/test_seo_schema.pydeleted file mode 100644index b492893907..0000000000--- a/saleor/seo/tests/test_seo_schema.py+++ /dev/null@@ -1,77 +0,0 @@-import json--import pytest--from ..schema.email import (- get_order_confirmation_markup,- get_organization,- get_product_data,-)---def test_get_organization(site_settings):- example_name = "Saleor Brand Name"- site = site_settings.site- site.name = example_name- site.save()-- result = get_organization()- assert result["name"] == example_name---def test_get_product_data_without_image(order_with_lines):- """Tested OrderLine Product has no image assigned."""- line = order_with_lines.lines.first()- organization = get_organization()- result = get_product_data(line, organization)- assert "image" not in result["itemOffered"]---def test_get_product_data_without_sku(order_with_lines):- """Tested OrderLine Product has no image assigned."""- line = order_with_lines.lines.first()- line.product_sku = None- line.save()-- organization = get_organization()- result = get_product_data(line, organization)- assert "image" not in result["itemOffered"]---def test_get_product_data_with_image(order_with_lines, product_with_image):- line = order_with_lines.lines.first()- variant = product_with_image.variants.first()- line.variant = variant- line.product_name = str(variant.product)- line.variant_name = str(variant)- line.save()- organization = get_organization()- result = get_product_data(line, organization)- assert "image" in result["itemOffered"]- assert result["itemOffered"]["name"] == variant.display_product()---def test_get_product_data_without_line_variant(order_with_lines):- """Tested OrderLine Product has no image assigned."""- line = order_with_lines.lines.first()- organization = get_organization()- line.variant = None- line.save()-- assert not line.variant- result = get_product_data(line, organization)-- assert result == {}---def test_get_order_confirmation_markup(order_with_lines):- try:- result = get_order_confirmation_markup(order_with_lines)- except TypeError:- pytest.fail("Function output is not JSON serializable")-- try:- # Response should be returned as a valid json- json.loads(result)- except ValueError:- pytest.fail("Response is not a valid json")