File tree Expand file tree Collapse file tree 3 files changed +26
-2
lines changed Expand file tree Collapse file tree 3 files changed +26
-2
lines changed Original file line number Diff line number Diff line change 46
46
CoreState ,
47
47
)
48
48
from ..coresys import CoreSysAttributes
49
- from ..exceptions import APIError , APIForbidden
49
+ from ..exceptions import APIError , APIForbidden , APINotFound
50
50
from ..jobs import JobSchedulerOptions
51
51
from ..mounts .const import MountUsage
52
52
from ..resolution .const import UnhealthyReason
@@ -134,7 +134,7 @@ def _extract_slug(self, request):
134
134
"""Return backup, throw an exception if it doesn't exist."""
135
135
backup = self .sys_backups .get (request .match_info .get ("slug" ))
136
136
if not backup :
137
- raise APIError ("Backup does not exist" )
137
+ raise APINotFound ("Backup does not exist" )
138
138
return backup
139
139
140
140
def _list_backups (self ):
Original file line number Diff line number Diff line change @@ -336,6 +336,12 @@ class APIForbidden(APIError):
336
336
status = 403
337
337
338
338
339
+ class APINotFound (APIError ):
340
+ """API not found error."""
341
+
342
+ status = 404
343
+
344
+
339
345
class APIAddonNotInstalled (APIError ):
340
346
"""Not installed addon requested at addons API."""
341
347
Original file line number Diff line number Diff line change @@ -729,3 +729,21 @@ async def test_upload_duplicate_backup_new_location(
729
729
".cloud_backup" : copy_backup ,
730
730
}
731
731
assert coresys .backups .get ("7fed74c8" ).location is None
732
+
733
+
734
+ @pytest .mark .parametrize (
735
+ ("method" , "url" ),
736
+ [
737
+ ("get" , "/backups/bad/info" ),
738
+ ("delete" , "/backups/bad" ),
739
+ ("post" , "/backups/bad/restore/full" ),
740
+ ("post" , "/backups/bad/restore/partial" ),
741
+ ("get" , "/backups/bad/download" ),
742
+ ],
743
+ )
744
+ async def test_backup_not_found (api_client : TestClient , method : str , url : str ):
745
+ """Test backup not found error."""
746
+ resp = await api_client .request (method , url )
747
+ assert resp .status == 404
748
+ resp = await resp .json ()
749
+ assert resp ["message" ] == "Backup does not exist"
You can’t perform that action at this time.
0 commit comments