fix: allow draft goal boards
This commit is contained in:
@@ -22,9 +22,11 @@ class BoardBase(SQLModel):
|
||||
class BoardCreate(BoardBase):
|
||||
@model_validator(mode="after")
|
||||
def validate_goal_fields(self):
|
||||
if self.board_type == "goal":
|
||||
if self.board_type == "goal" and self.goal_confirmed:
|
||||
if not self.objective or not self.success_metrics:
|
||||
raise ValueError("Goal boards require objective and success_metrics")
|
||||
raise ValueError(
|
||||
"Confirmed goal boards require objective and success_metrics"
|
||||
)
|
||||
return self
|
||||
|
||||
|
||||
|
||||
@@ -3,18 +3,28 @@ import pytest
|
||||
from app.schemas.boards import BoardCreate
|
||||
|
||||
|
||||
def test_goal_board_requires_objective_and_metrics():
|
||||
def test_goal_board_requires_objective_and_metrics_when_confirmed():
|
||||
with pytest.raises(ValueError):
|
||||
BoardCreate(name="Goal Board", slug="goal", board_type="goal")
|
||||
BoardCreate(
|
||||
name="Goal Board",
|
||||
slug="goal",
|
||||
board_type="goal",
|
||||
goal_confirmed=True,
|
||||
)
|
||||
|
||||
BoardCreate(
|
||||
name="Goal Board",
|
||||
slug="goal",
|
||||
board_type="goal",
|
||||
goal_confirmed=True,
|
||||
objective="Launch onboarding",
|
||||
success_metrics={"emails": 3},
|
||||
)
|
||||
|
||||
|
||||
def test_goal_board_allows_missing_objective_before_confirmation():
|
||||
BoardCreate(name="Draft", slug="draft", board_type="goal")
|
||||
|
||||
|
||||
def test_general_board_allows_missing_objective():
|
||||
BoardCreate(name="General", slug="general", board_type="general")
|
||||
|
||||
Reference in New Issue
Block a user