forked from saleor/saleor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_seo_schema.py
49 lines (37 loc) · 1.48 KB
/
test_seo_schema.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import json
import pytest
from saleor.seo.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_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 = variant.display_product()
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_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')