♻️(backend) update is_savable method

A recording is savable only if it's active or stopped. In other
status (error, already saved, etc.) it won't be possible. I might
iterate on this piece of code. Let's ship it.
This commit is contained in:
lebaudantoine
2024-11-08 16:49:05 +01:00
committed by aleb_the_flash
parent 8309545ec6
commit e11bdc6d28
2 changed files with 10 additions and 4 deletions

View File

@@ -540,10 +540,10 @@ class Recording(BaseModel):
def is_savable(self) -> bool:
"""Determine if the recording can be saved based on its current status."""
is_unsuccessful = RecordingStatusChoices.is_unsuccessful(self.status)
is_already_saved = self.status == RecordingStatusChoices.SAVED
return not is_unsuccessful and not is_already_saved
return self.status in {
RecordingStatusChoices.ACTIVE,
RecordingStatusChoices.STOPPED,
}
class RecordingAccess(BaseAccess):

View File

@@ -173,6 +173,12 @@ def test_models_recording_is_savable_already_saved():
assert recording.is_savable() is False
def test_models_recording_is_savable_only_initiated():
"""Test is_savable for only initiated recording."""
recording = RecordingFactory(status=RecordingStatusChoices.INITIATED)
assert recording.is_savable() is False
# Test few corner cases