File tree 6 files changed +16
-12
lines changed
services/payments/src/simcore_service_payments
6 files changed +16
-12
lines changed Original file line number Diff line number Diff line change 5
5
_logger = logging .getLogger (__name__ )
6
6
7
7
8
- class AppStateMixin :
8
+ class SingletonInAppStateMixin :
9
9
"""
10
10
Mixin to get, set and delete an instance of 'self' from/to app.state
11
11
"""
Original file line number Diff line number Diff line change 13
13
from asgi_lifespan import LifespanManager
14
14
from fastapi import FastAPI , status
15
15
from models_library .healthchecks import IsResponsive
16
- from servicelib .fastapi .app_state import AppStateMixin
16
+ from servicelib .fastapi .app_state import SingletonInAppStateMixin
17
17
from servicelib .fastapi .http_client import BaseHttpApi
18
18
19
19
20
20
def test_using_app_state_mixin ():
21
- class SomeData (AppStateMixin ):
21
+ class SomeData (SingletonInAppStateMixin ):
22
22
app_state_name : str = "my_data"
23
23
frozen : bool = True
24
24
@@ -71,7 +71,7 @@ def mock_server_api(base_url: str) -> Iterator[respx.MockRouter]:
71
71
72
72
73
73
async def test_base_http_api (mock_server_api : respx .MockRouter , base_url : str ):
74
- class MyClientApi (BaseHttpApi , AppStateMixin ):
74
+ class MyClientApi (BaseHttpApi , SingletonInAppStateMixin ):
75
75
app_state_name : str = "my_client_api"
76
76
77
77
new_app = FastAPI ()
Original file line number Diff line number Diff line change 4
4
5
5
from fastapi import Depends , FastAPI , Request
6
6
from fastapi .security import OAuth2PasswordBearer
7
- from servicelib .fastapi .app_state import AppStateMixin
7
+ from servicelib .fastapi .app_state import SingletonInAppStateMixin
8
8
from servicelib .fastapi .dependencies import get_app , get_reverse_url_mapper
9
9
from sqlalchemy .ext .asyncio import AsyncEngine
10
10
@@ -44,7 +44,9 @@ def get_rut_api(request: Request) -> ResourceUsageTrackerApi:
44
44
)
45
45
46
46
47
- def get_from_app_state (app_state_mixin_subclass : type [AppStateMixin ]) -> Callable :
47
+ def get_from_app_state (
48
+ app_state_mixin_subclass : type [SingletonInAppStateMixin ],
49
+ ) -> Callable :
48
50
"""Generic getter of app.state objects"""
49
51
50
52
def _ (app : Annotated [FastAPI , Depends (get_app )]):
Original file line number Diff line number Diff line change 13
13
PaymentTransaction ,
14
14
)
15
15
from models_library .users import UserID
16
- from servicelib .fastapi .app_state import AppStateMixin
16
+ from servicelib .fastapi .app_state import SingletonInAppStateMixin
17
17
18
18
from ..db .payment_users_repo import PaymentsUsersRepo
19
19
from .postgres import get_engine
20
20
21
21
_logger = logging .getLogger (__name__ )
22
22
23
23
24
- class Notifier (AppStateMixin ):
24
+ class Notifier (SingletonInAppStateMixin ):
25
25
app_state_name : str = "notifier"
26
26
27
27
def __init__ (
Original file line number Diff line number Diff line change 18
18
from models_library .api_schemas_webserver .wallets import PaymentID , PaymentMethodID
19
19
from pydantic import ValidationError , parse_raw_as
20
20
from pydantic .errors import PydanticErrorMixin
21
- from servicelib .fastapi .http_client import AppStateMixin , BaseHttpApi , to_curl_command
21
+ from servicelib .fastapi .app_state import SingletonInAppStateMixin
22
+ from servicelib .fastapi .http_client import BaseHttpApi
23
+ from servicelib .fastapi .httpx_utils import to_curl_command
22
24
from simcore_service_payments .models .schemas .acknowledgements import (
23
25
AckPaymentWithPaymentMethod ,
24
26
)
@@ -105,7 +107,7 @@ def auth_flow(self, request):
105
107
yield request
106
108
107
109
108
- class PaymentsGatewayApi (BaseHttpApi , AppStateMixin ):
110
+ class PaymentsGatewayApi (BaseHttpApi , SingletonInAppStateMixin ):
109
111
app_state_name : str = "payment_gateway_api"
110
112
111
113
#
Original file line number Diff line number Diff line change 19
19
from models_library .resource_tracker import CreditTransactionId
20
20
from models_library .users import UserID
21
21
from models_library .wallets import WalletID
22
- from servicelib .fastapi .app_state import AppStateMixin
22
+ from servicelib .fastapi .app_state import SingletonInAppStateMixin
23
23
from servicelib .fastapi .http_client import BaseHttpApi
24
24
25
25
from ..core .settings import ApplicationSettings
26
26
27
27
_logger = logging .getLogger (__name__ )
28
28
29
29
30
- class ResourceUsageTrackerApi (BaseHttpApi , AppStateMixin ):
30
+ class ResourceUsageTrackerApi (BaseHttpApi , SingletonInAppStateMixin ):
31
31
app_state_name : str = "source_usage_tracker_api"
32
32
33
33
async def create_credit_transaction (
You can’t perform that action at this time.
0 commit comments