import pytest from heleos.config import Site from heleos.errors import ValidationError def test_wordpress_forces_database(): s = Site.from_dict({"customer": "acme", "site": "blog", "profile": "wordpress", "domains": ["blog.acme.com"], "database": False}) assert s.database is True def test_redirect_requires_target(): with pytest.raises(ValidationError): Site.from_dict({"customer": "acme", "site": "old", "profile": "redirect", "domains": ["old.acme.com"]}) def test_redirect_needs_source_domain(): with pytest.raises(ValidationError): Site.from_dict({"customer": "acme", "site": "old", "profile": "redirect", "domains": [], "redirect_to": "https://acme.com"}) def test_static_cannot_have_database(): with pytest.raises(ValidationError): Site.from_dict({"customer": "acme", "site": "site", "profile": "static", "domains": ["acme.com"], "database": True}) def test_unknown_profile_rejected(): with pytest.raises(ValidationError): Site.from_dict({"customer": "acme", "site": "x", "profile": "django", "domains": ["acme.com"]})