feat: add full project - backend, frontend, docker, specs and configs
This commit is contained in:
parent
b77c7d5a01
commit
e6cb06255b
24489 changed files with 61341 additions and 36 deletions
46
backend/tests/test_homepage.py
Normal file
46
backend/tests/test_homepage.py
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from app.models.homepage import HomepageConfig
|
||||
from app.schemas.homepage import HomepageConfigIn
|
||||
|
||||
|
||||
def test_get_homepage_config_returns_200(client, db):
|
||||
"""GET /api/v1/homepage-config returns 200 with required fields when config exists."""
|
||||
config = HomepageConfig(
|
||||
hero_headline="Teste Headline",
|
||||
hero_subheadline="Subtítulo de teste",
|
||||
hero_cta_label="Ver Imóveis",
|
||||
hero_cta_url="/imoveis",
|
||||
featured_properties_limit=6,
|
||||
)
|
||||
db.session.add(config)
|
||||
db.session.commit()
|
||||
|
||||
response = client.get("/api/v1/homepage-config")
|
||||
assert response.status_code == 200
|
||||
|
||||
data = response.get_json()
|
||||
assert data["hero_headline"] == "Teste Headline"
|
||||
assert data["hero_subheadline"] == "Subtítulo de teste"
|
||||
assert data["hero_cta_label"] == "Ver Imóveis"
|
||||
assert data["hero_cta_url"] == "/imoveis"
|
||||
assert data["featured_properties_limit"] == 6
|
||||
|
||||
|
||||
def test_get_homepage_config_returns_404_when_empty(client, db):
|
||||
"""GET /api/v1/homepage-config returns 404 when no config record exists."""
|
||||
response = client.get("/api/v1/homepage-config")
|
||||
assert response.status_code == 404
|
||||
|
||||
data = response.get_json()
|
||||
assert "error" in data
|
||||
|
||||
|
||||
def test_homepage_config_in_rejects_empty_headline():
|
||||
"""HomepageConfigIn raises ValidationError when hero_headline is empty."""
|
||||
with pytest.raises(ValidationError) as exc_info:
|
||||
HomepageConfigIn(hero_headline="")
|
||||
|
||||
errors = exc_info.value.errors()
|
||||
assert any("hero_headline" in str(e) for e in errors)
|
||||
Loading…
Add table
Add a link
Reference in a new issue