Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions marble_api/versions/v1/survey/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ class Survey(MarbleBaseModel):
"""Survey containing questions."""

user_visible: bool
title: str = Field(..., min_length=1)
questions: list[TextQuestion | ChoiceQuestion] = Field(..., min_length=1)


Expand Down
2 changes: 1 addition & 1 deletion marble_api/versions/v1/survey/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ async def get_surveys(
after: str | None = None,
before: str | None = None,
limit: Annotated[int, Query(le=100, gt=0)] = 10,
sort_by: Literal["id", "created", "updated", "user_visible"] = "id",
sort_by: Literal["id", "created", "updated", "user_visible", "title"] = "id",
ascending: bool = True,
) -> SurveysResponse:
"""
Expand Down
1 change: 1 addition & 0 deletions test/faker_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ def _survey_inputs(self, unset=None):
updated=self.generator.tz_aware_date_time_seconds_precision(),
user=self.generator.profile("username")["username"],
user_visible=self.generator.pybool(),
title=self.generator.pystr(),
questions=[self.question() for _ in range(self.generator.random.randint(1, 10))],
)
if unset:
Expand Down
2 changes: 1 addition & 1 deletion test/integration/versions/v1/survey/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class _TestGetManySurvey(_TestGetSurvey, GetManyTest):
n_records = default_link_limit * 2 + 2
n_records_return_count: int
records_key = "surveys"
sort_keys = ("id", "created", "updated", "user_visible")
sort_keys = ("id", "created", "updated", "user_visible", "title")

@pytest.fixture(autouse=True, scope="class")
@classmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,10 @@ def test_at_least_one_question(self, fake_class):
with pytest.raises(ValidationError):
fake_class(questions=[])

def test_title_required(self, fake_class):
with pytest.raises(ValidationError):
fake_class(title="")


class TestSurvey(_TestSurvey, _TestMarbleBaseModel):
@pytest.fixture
Expand Down
Loading