Skip to content

Commit

Permalink
test that STATE_STR_CONVERSION does contain all States
Browse files Browse the repository at this point in the history
  • Loading branch information
fekoch committed Apr 29, 2024
1 parent d48a261 commit 66a16a1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
10 changes: 2 additions & 8 deletions evap/evaluation/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from django_fsm import FSMIntegerField, transition
from django_fsm.signals import post_transition

from evap.evaluation.models_logging import FieldAction, LoggedModel
from evap.evaluation.models_logging import LoggedModel
from evap.evaluation.tools import (
StrOrPromise,
clean_email,
Expand Down Expand Up @@ -403,17 +403,11 @@ class State(IntEnum):
State.PUBLISHED: _("published"),
}

# TODO@Felix: test that choices contains all States
state = FSMIntegerField(
default=State.NEW, choices=STATE_STR_CONVERSION.items(), protected=True,
verbose_name=_("state")
)

# state = FSMIntegerField(
# default=State.NEW, choices=[(s, "STATE_STR_CONVERSION[s]") for s in State], protected=True,
# verbose_name=_("state")
# )

course = models.ForeignKey(Course, models.PROTECT, verbose_name=_("course"), related_name="evaluations")

# names can be empty, e.g., when there is just one evaluation in a course
Expand Down Expand Up @@ -829,7 +823,7 @@ def state_to_str(cls, state: "Evaluation.State") -> StrOrPromise:

@property
def state_str(self):
return self.state_to_str(self.state)
return Evaluation.state_to_str(Evaluation.State(self.state))

@cached_property
def general_contribution(self):
Expand Down
4 changes: 4 additions & 0 deletions evap/evaluation/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,10 @@ def test_textanswer_review_state(self):
evaluation.TextAnswerReviewState.REVIEWED,
)

def test_STATE_STR_CONVERSION_contains_all_states(self):
for state in Evaluation.State:
self.assertIn(state, Evaluation.STATE_STR_CONVERSION)


class TestCourse(TestCase):
def test_can_be_deleted_by_manager(self):
Expand Down

0 comments on commit 66a16a1

Please sign in to comment.