Coverage for src/kwai/modules/identity/users/user.py: 100%
18 statements
« prev ^ index » next coverage.py v7.6.10, created at 2024-01-01 00:00 +0000
« prev ^ index » next coverage.py v7.6.10, created at 2024-01-01 00:00 +0000
1"""Module that implements a User entity."""
3from dataclasses import dataclass, field
4from typing import ClassVar, Type
6from kwai.core.domain.entity import DataclassEntity
7from kwai.core.domain.value_objects.email_address import EmailAddress
8from kwai.core.domain.value_objects.identifier import IntIdentifier
9from kwai.core.domain.value_objects.name import Name
10from kwai.core.domain.value_objects.owner import Owner
11from kwai.core.domain.value_objects.unique_id import UniqueId
14class UserIdentifier(IntIdentifier):
15 """Identifier for a user entity."""
18@dataclass(kw_only=True, eq=False, slots=True, frozen=True)
19class UserEntity(DataclassEntity):
20 """A user entity."""
22 ID: ClassVar[Type] = UserIdentifier
24 name: Name
25 email: EmailAddress
26 uuid: UniqueId = field(default_factory=UniqueId.generate)
27 remark: str = ""
29 def create_owner(self) -> Owner:
30 """Create an owner value object from the user entity."""
31 return Owner(id=self.id, uuid=self.uuid, name=self.name)