File tree Expand file tree Collapse file tree 4 files changed +18
-7
lines changed
src/simcore_service_webserver/products
tests/unit/with_dbs/04/products Expand file tree Collapse file tree 4 files changed +18
-7
lines changed Original file line number Diff line number Diff line change 66 exception_handling_decorator ,
77 to_exceptions_handlers_map ,
88)
9- from ..errors import ProductNotFoundError
9+ from ..errors import MissingStripeConfigError , ProductNotFoundError
1010
1111_TO_HTTP_ERROR_MAP : ExceptionToHttpErrorMap = {
1212 ProductNotFoundError : HttpErrorInfo (
1313 status .HTTP_404_NOT_FOUND , "{product_name} was not found"
1414 ),
15+ MissingStripeConfigError : HttpErrorInfo (
16+ status .HTTP_503_SERVICE_UNAVAILABLE , MissingStripeConfigError .msg_template
17+ ),
1518}
1619
1720
Original file line number Diff line number Diff line change 1212from ._repository import ProductRepository
1313from .errors import (
1414 BelowMinimumPaymentError ,
15+ MissingStripeConfigError ,
1516 ProductNotFoundError ,
1617 ProductPriceNotDefinedError ,
1718 ProductTemplateNotFoundError ,
@@ -116,8 +117,9 @@ async def get_product_stripe_info(
116117 or "missing!!" in product_stripe_info .stripe_price_id
117118 or "missing!!" in product_stripe_info .stripe_tax_rate_id
118119 ):
119- msg = f"Missing product stripe for product { product_name } "
120- raise ValueError (msg )
120+ raise MissingStripeConfigError (
121+ product_name = product_name , product_stripe_info = product_stripe_info
122+ )
121123 return product_stripe_info
122124
123125
Original file line number Diff line number Diff line change 11from ..errors import WebServerBaseError
22
33
4- class ProductError (WebServerBaseError , ValueError ):
5- ...
4+ class ProductError (WebServerBaseError , ValueError ): ...
65
76
87class ProductNotFoundError (ProductError ):
@@ -19,3 +18,7 @@ class BelowMinimumPaymentError(ProductError):
1918
2019class ProductTemplateNotFoundError (ProductError ):
2120 msg_template = "Missing template {template_name} for product"
21+
22+
23+ class MissingStripeConfigError (ProductError ):
24+ msg_template = "Missing product stripe for product {product_name}"
Original file line number Diff line number Diff line change 1010from models_library .products import ProductName
1111from simcore_service_webserver .products import products_service
1212from simcore_service_webserver .products ._repository import ProductRepository
13- from simcore_service_webserver .products .errors import ProductPriceNotDefinedError
13+ from simcore_service_webserver .products .errors import (
14+ MissingStripeConfigError ,
15+ ProductPriceNotDefinedError ,
16+ )
1417
1518
1619@pytest .fixture
@@ -46,7 +49,7 @@ async def test_get_product_stripe_info(
4649 # this feature is currently setup from adminer by an operator
4750
4851 # default is not configured
49- with pytest .raises (ValueError , match = default_product_name ):
52+ with pytest .raises (MissingStripeConfigError , match = default_product_name ):
5053 await products_service .get_product_stripe_info (
5154 app , product_name = default_product_name
5255 )
You can’t perform that action at this time.
0 commit comments