Coverage for src / history / model_data.py: 100%

39 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2026-04-16 12:53 +0000

1from datetime import datetime 

2from enum import StrEnum 

3from typing import TYPE_CHECKING, Literal, NotRequired, TypedDict 

4 

5if TYPE_CHECKING: 

6 from ptf.models import Collection, Resource 

7 

8 

9class HistoryEventStatus(StrEnum): 

10 OK = "OK" 

11 WARNING = "WARNING" 

12 ERROR = "ERROR" 

13 PENDING = "PENDING" 

14 

15 

16class MatchingEventResult(StrEnum): 

17 ADDED = "added" 

18 ALREADY_PRESENT = "already_present" 

19 NOT_FOUND = "not_found" 

20 LOW_SCORE = "score_too_low" 

21 SKIPPED = "skipped" 

22 

23 

24HistoryEventType = Literal[ 

25 "edit", 

26 "marching", 

27 "deploy", 

28 "clockss", 

29 "archive", 

30 "archive-collections", 

31 "augment", 

32 "import", 

33 "download_pdf", 

34 "matching", 

35 "import-source", 

36 "tex_conversion", 

37] 

38 

39 

40class HistoryEventDict(TypedDict): 

41 type: HistoryEventType 

42 pid: str 

43 col: "Collection | None" 

44 

45 source: NotRequired[str] 

46 unique_id: NotRequired[str] 

47 

48 parent_id: NotRequired[str] 

49 status: NotRequired["HistoryEventStatus"] 

50 title: NotRequired[str] 

51 userid: NotRequired[str] 

52 type_error: NotRequired[str] 

53 

54 created_on: NotRequired[datetime] 

55 message: NotRequired[str] 

56 

57 children: NotRequired[list["HistoryChildDict"]] 

58 

59 

60class HistoryChildDict(TypedDict): 

61 resource: "Resource" 

62 type: str 

63 status: str 

64 status_message: NotRequired[str] 

65 message: NotRequired[str] 

66 score: NotRequired[int] 

67 "Matching score for an item" 

68 url: NotRequired[str] 

69 "Matching url of the remote resource"