| 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(): |
| |
| 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 |
|
|