Coverage for postrfp/shared/serial/common.py: 100%

26 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2025-10-22 21:34 +0000

1from datetime import datetime 

2from typing import Optional 

3from enum import StrEnum 

4 

5from pydantic import BaseModel, ConfigDict, Field 

6 

7# Import shared pagination schema to avoid duplication and circular imports 

8# Re-export for backward compatibility 

9 

10 

11class Id(BaseModel): 

12 model_config = ConfigDict(from_attributes=True) 

13 id: Optional[int] = None 

14 

15 

16class StringId(BaseModel): 

17 id: str 

18 

19 

20class TimestampedId(Id): 

21 """ 

22 Provides id, date_created and date_updated fields 

23 """ 

24 

25 date_created: Optional[datetime] = None 

26 date_updated: Optional[datetime] = None 

27 

28 

29class ScoringModel(StrEnum): 

30 """ 

31 Enum for score types 

32 """ 

33 

34 UNWEIGHTED = "Unweighted" 

35 DIRECT = "Direct" 

36 ABSOLUTE = "Absolute" 

37 

38 def __str__(self): 

39 return self.value 

40 

41 

42class Pagination(BaseModel): 

43 """Schema for pagination information.""" 

44 

45 current_page: int 

46 page_size: int 

47 total_count: int 

48 total_pages: int 

49 has_next: bool 

50 current_page_count: int = Field( 

51 0, description="Number of records in the current page" 

52 ) 

53 

54 

55__all__ = ["Pagination", "Id", "StringId", "TimestampedId", "ScoringModel"]