Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Tests for SEO helpers
Pacu28ee567f86606
diff --git a/tests/test_collection.py b/tests/test_collection.pyindex 09a1b95ee6..3544920903 100644--- a/tests/test_collection.py+++ b/tests/test_collection.py@@ -1,3 +1,5 @@+import pytest+from django.urls import reversefrom .utils import get_redirect_location@@ -25,8 +27,36 @@ def test_collection_incorrect_slug(client, collection):proper_url = reverse('product:collection', kwargs=proper_kwargs)assert redirected_url == proper_url+def test_collection_not_exists(client):url_kwargs = {'pk': 123456, 'slug': 'incorrect-slug'}url = reverse('product:collection', kwargs=url_kwargs)response = client.get(url)assert response.status_code == 404+++ 'title, seo_title, expected_result',+ (+ ('Title', 'Seo Title', 'Seo Title'),+ ('Title', None, 'Title')))+def test_page_get_seo_title(+ admin_client, collection, title, seo_title, expected_result):+ collection.name = title+ collection.seo_title = seo_title+ collection.save()+ result = collection.get_seo_title()+ expected_result == result+++ 'seo_description, expected_result',+ (+ ('Seo', 'Seo'),+ (None, '')))+def test_page_get_seo_description(+ admin_client, collection, seo_description, expected_result):+ collection.seo_description = seo_description+ collection.save()+ result = collection.get_seo_description()+ expected_result == resultdiff --git a/tests/test_page.py b/tests/test_page.pyindex f89ff57979..5880450860 100644--- a/tests/test_page.py+++ b/tests/test_page.py@@ -1,3 +1,6 @@+import pytest++def test_draft_page_detail(client, admin_client, page):page_url = page.get_absolute_url()response = client.get(page_url)@@ -14,3 +17,30 @@ def test_public_page_detail(client, admin_client, page):assert response.status_code == 200response = admin_client.get(page_url)assert response.status_code == 200+++ 'title, seo_title, expected_result',+ (+ ('Title', 'Seo Title', 'Seo Title'),+ ('Title', None, 'Title')))+def test_page_get_seo_title(+ admin_client, page, title, seo_title, expected_result):+ page.title = title+ page.seo_title = seo_title+ page.save()+ result = page.get_seo_title()+ expected_result == result+++ 'seo_description, expected_result',+ (+ ('Seo', 'Seo'),+ (None, '')))+def test_page_get_seo_description(+ admin_client, page, seo_description, expected_result):+ page.seo_description = seo_description+ page.save()+ result = page.get_seo_description()+ expected_result == resultdiff --git a/tests/test_product.py b/tests/test_product.pyindex cfc83a7712..f850775167 100644--- a/tests/test_product.py+++ b/tests/test_product.py@@ -532,3 +532,61 @@ def test_include_products_from_subcategories_in_main_view('path': path, 'category_id': default_category.pk})response = authorized_client.get(url)assert product in response.context_data['products'][0]+++ 'title, seo_title, expected_result',+ (+ ('Title', 'Seo Title', 'Seo Title'),+ ('Title', None, 'Title')))+def test_product_get_seo_title(+ admin_client, product_in_stock, title, seo_title, expected_result):+ product_in_stock.name = title+ product_in_stock.seo_title = seo_title+ product_in_stock.save()+ result = product_in_stock.get_seo_title()+ expected_result == result+++ 'description, seo_description, expected_result',+ (+ ('Description', 'Seo', 'Seo'),+ ('Description', None, '')))+def test_product_get_seo_description(+ admin_client, product_in_stock, description, seo_description,+ expected_result):+ product_in_stock.description = description+ product_in_stock.seo_description = seo_description+ product_in_stock.save()+ result = product_in_stock.get_seo_description()+ expected_result == result+++ 'title, seo_title, expected_result',+ (+ ('Title', 'Seo Title', 'Seo Title'),+ ('Title', None, 'Title')))+def test_category_get_seo_title(+ admin_client, default_category, title, seo_title, expected_result):+ default_category.name = title+ default_category.seo_title = seo_title+ default_category.save()+ result = default_category.get_seo_title()+ expected_result == result+++ 'description, seo_description, expected_result',+ (+ ('Description', 'Seo', 'Seo'),+ ('Description', None, '')))+def test_category_get_seo_description(+ admin_client, default_category, description, seo_description,+ expected_result):+ default_category.description = description+ default_category.seo_description = seo_description+ default_category.save()+ result = default_category.get_seo_description()+ expected_result == result