Coverage for src/lexigram/admin/auth/store/base.py: 100%

15 statements  

« prev     ^ index     » next       coverage.py v7.15.4, created at 2026-08-21 14:26 +0800

1""" 

2Base admin user store interface. 

3""" 

4 

5from __future__ import annotations 

6 

7from abc import ABC, abstractmethod 

8from typing import TYPE_CHECKING 

9 

10if TYPE_CHECKING: 

11 from lexigram.contracts.auth import AuthenticatedUserProtocol 

12 

13 

14class AbstractAdminUserStore(ABC): 

15 """Abstract base class for admin user stores. 

16 

17 Provides the interface for admin user operations including 

18 authentication, user lookup, and user management. 

19 """ 

20 

21 @abstractmethod 

22 async def get_by_id(self, user_id: str) -> AuthenticatedUserProtocol | None: 

23 """Get user by ID.""" 

24 ... 

25 

26 @abstractmethod 

27 async def get_by_email(self, email: str) -> AuthenticatedUserProtocol | None: 

28 """Get user by email address.""" 

29 ... 

30 

31 @abstractmethod 

32 async def get_by_username(self, username: str) -> AuthenticatedUserProtocol | None: 

33 """Get user by username.""" 

34 ... 

35 

36 @abstractmethod 

37 async def authenticate( 

38 self, email: str, password: str 

39 ) -> AuthenticatedUserProtocol | None: 

40 """Authenticate user by email and password.""" 

41 ... 

42 

43 @abstractmethod 

44 async def count(self) -> int: 

45 """Get total number of users.""" 

46 ... 

47 

48 

49__all__ = ["AbstractAdminUserStore"]