Skip to content

Commit b58bad1

Browse files
committed
errors.py
1 parent e543cfd commit b58bad1

File tree

4 files changed

+127
-206
lines changed

4 files changed

+127
-206
lines changed

lambdas/mns_subscription/src/mns_service.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import logging
55
import json
66
from common.authentication import AppRestrictedAuth
7-
from models.errors import (
7+
from common.models.errors import (
88
UnhandledResponseError,
99
ResourceNotFoundError,
1010
UnauthorizedError,
@@ -129,4 +129,6 @@ def raise_error_response(response):
129129
response.status_code,
130130
(UnhandledResponseError, f"Unhandled error: {response.status_code}"))
131131

132+
if response.status_code == 404:
133+
raise exception_class(resource_type=response.json(), resource_id=error_message)
132134
raise exception_class(response=response.json(), message=error_message)

lambdas/mns_subscription/src/models/errors.py

Lines changed: 0 additions & 177 deletions
This file was deleted.

lambdas/mns_subscription/tests/test_mns_service.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from unittest.mock import patch, MagicMock, Mock, create_autospec
44
from mns_service import MnsService, MNS_URL
55
from common.authentication import AppRestrictedAuth
6-
from models.errors import (
6+
from common.models.errors import (
77
ServerError,
88
UnhandledResponseError,
99
TokenValidationError,
@@ -266,8 +266,8 @@ def test_404_resource_found_error(self):
266266
with self.assertRaises(ResourceNotFoundError) as context:
267267
MnsService.raise_error_response(resp)
268268
self.assertIn("Subscription or Resource not found", str(context.exception))
269-
self.assertEqual(context.exception.message, "Subscription or Resource not found")
270-
self.assertEqual(context.exception.response, {"resource": "Not found"})
269+
self.assertEqual(context.exception.resource_id, "Subscription or Resource not found")
270+
self.assertEqual(context.exception.resource_type, {"resource": "Not found"})
271271

272272
def test_400_bad_request_error(self):
273273
resp = self.mock_response(400, {"resource": "Invalid"})

0 commit comments

Comments
 (0)