♻️(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:
committed by
aleb_the_flash
parent
8309545ec6
commit
e11bdc6d28
@@ -540,10 +540,10 @@ class Recording(BaseModel):
|
|||||||
def is_savable(self) -> bool:
|
def is_savable(self) -> bool:
|
||||||
"""Determine if the recording can be saved based on its current status."""
|
"""Determine if the recording can be saved based on its current status."""
|
||||||
|
|
||||||
is_unsuccessful = RecordingStatusChoices.is_unsuccessful(self.status)
|
return self.status in {
|
||||||
is_already_saved = self.status == RecordingStatusChoices.SAVED
|
RecordingStatusChoices.ACTIVE,
|
||||||
|
RecordingStatusChoices.STOPPED,
|
||||||
return not is_unsuccessful and not is_already_saved
|
}
|
||||||
|
|
||||||
|
|
||||||
class RecordingAccess(BaseAccess):
|
class RecordingAccess(BaseAccess):
|
||||||
|
|||||||
@@ -173,6 +173,12 @@ def test_models_recording_is_savable_already_saved():
|
|||||||
assert recording.is_savable() is False
|
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
|
# Test few corner cases
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user