Coverage for app/ddd/infrastructure/factory/token_factory_impl.py: 100%
10 statements
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-15 01:44 +0000
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-15 01:44 +0000
1import os
2from datetime import timedelta
4from app.ddd.domain.factory import TokenFactory
5from app.ddd.domain.model import Token, User
6from app.ddd.infrastructure.auth import create_access_token
9class TokenFactoryImpl(TokenFactory):
10 def __init__(self, expires_minites: int = 1) -> None:
11 self.expires_minites = expires_minites
12 def create(self, user: User) -> Token:
13 return Token(
14 access_token = create_access_token(
15 expires_delta=timedelta(self.expires_minites),
16 data={"sub": user.user_id},
17 ),
18 token_type =os.environ["TOKEN_TYPE"]
19 )