File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed
cogstack_model_gateway/common Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,9 @@ class Status(str, Enum):
1818 FAILED = "failed"
1919 REQUEUED = "requeued"
2020
21+ def is_final (self ) -> bool :
22+ return self in {self .SUCCEEDED , self .FAILED }
23+
2124
2225class Task (SQLModel , table = True ):
2326 uuid : str = Field (default_factory = lambda : str (uuid .uuid4 ()), primary_key = True )
Original file line number Diff line number Diff line change @@ -26,6 +26,13 @@ def task_manager(db_manager: Session) -> TaskManager:
2626 return TaskManager (db_manager )
2727
2828
29+ def test_status_enum () -> None :
30+ for status in Status :
31+ assert isinstance (status , Status )
32+ assert isinstance (status .value , str )
33+ assert status .is_final () == (status in {Status .SUCCEEDED , Status .FAILED })
34+
35+
2936def test_create_task (task_manager : TaskManager ) -> None :
3037 """Test creating a task with different statuses."""
3138 task_uuid = task_manager .create_task (status = Status .PENDING )
You can’t perform that action at this time.
0 commit comments