add abandoned status to distinguish given-up habits from completed ones

Completed and abandoned habits were both lumped under a single terminal
state, making it impossible to tell "finished successfully" apart from
"gave up" when reviewing habit history.
This commit is contained in:
2026-07-17 20:19:35 +09:00
parent d0dd530e26
commit 55918d56d1
11 changed files with 167 additions and 3 deletions
+24
View File
@@ -86,6 +86,30 @@ def test_complete_and_reactivate_habit(db_session, test_user):
assert reactivated.completed_at is None
def test_abandon_and_reactivate_habit(db_session, test_user):
habit = _make_habit(db_session, test_user.id)
abandoned = habit_service.abandon_habit(db_session, habit)
assert abandoned.status == HabitStatus.ABANDONED
assert abandoned.abandoned_at is not None
reactivated = habit_service.reactivate_habit(db_session, habit)
assert reactivated.status == HabitStatus.ACTIVE
assert reactivated.abandoned_at is None
def test_list_habits_filters_by_abandoned_status(db_session, test_user):
build = _make_habit(db_session, test_user.id, name="빌드")
quit_ = _make_habit(db_session, test_user.id, name="퀴트", habit_type=HabitType.QUIT)
habit_service.abandon_habit(db_session, quit_)
active = habit_service.list_habits(db_session, test_user.id, status=HabitStatus.ACTIVE)
assert [h.id for h in active] == [build.id]
abandoned = habit_service.list_habits(db_session, test_user.id, status=HabitStatus.ABANDONED)
assert [h.id for h in abandoned] == [quit_.id]
def test_reorder_habits_applies_given_order(db_session, test_user):
a = _make_habit(db_session, test_user.id, name="A")
b = _make_habit(db_session, test_user.id, name="B")