flexigo-support-bot / tests /test_schemas_shop.py
victor34593993's picture
review fixes
242c945 verified
Raw
History Blame Contribute Delete
800 Bytes
from __future__ import annotations
import pytest
from pydantic import ValidationError
from app.schemas import TenantIn, TenantUpdate
def test_shop_normalized_to_bare_myshopify_domain():
t = TenantIn(slug="xx", shopify_shop="HTTPS://Acme-Store.myshopify.com/")
assert t.shopify_shop == "acme-store.myshopify.com"
def test_non_myshopify_shop_rejected():
# the OAuth secret must never be sendable to a non-Shopify host
with pytest.raises(ValidationError):
TenantIn(slug="xx", shopify_shop="evil.example.com")
with pytest.raises(ValidationError):
TenantUpdate(shopify_shop="attacker.myshopify.com.evil.com")
def test_empty_shop_is_none():
assert TenantIn(slug="xx", shopify_shop="").shopify_shop is None
assert TenantIn(slug="xx").shopify_shop is None