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 4646 CoreState ,
4747)
4848from ..coresys import CoreSysAttributes
49- from ..exceptions import APIError , APIForbidden
49+ from ..exceptions import APIError , APIForbidden , APINotFound
5050from ..jobs import JobSchedulerOptions
5151from ..mounts .const import MountUsage
5252from ..resolution .const import UnhealthyReason
@@ -134,7 +134,7 @@ def _extract_slug(self, request):
134134 """Return backup, throw an exception if it doesn't exist."""
135135 backup = self .sys_backups .get (request .match_info .get ("slug" ))
136136 if not backup :
137- raise APIError ("Backup does not exist" )
137+ raise APINotFound ("Backup does not exist" )
138138 return backup
139139
140140 def _list_backups (self ):
Original file line number Diff line number Diff line change @@ -336,6 +336,12 @@ class APIForbidden(APIError):
336336 status = 403
337337
338338
339+ class APINotFound (APIError ):
340+ """API not found error."""
341+
342+ status = 404
343+
344+
339345class APIAddonNotInstalled (APIError ):
340346 """Not installed addon requested at addons API."""
341347
Original file line number Diff line number Diff line change @@ -729,3 +729,21 @@ async def test_upload_duplicate_backup_new_location(
729729 ".cloud_backup" : copy_backup ,
730730 }
731731 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