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

39 statements  

« prev     ^ index     » next       coverage.py v7.15.4, created at 2026-08-14 10:02 +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-source", 

33 "import-collection", 

34 "download-pdf", 

35 "download-collection", 

36 "download-source", 

37 "download-sources", 

38 "matching", 

39 "import-source", 

40 "tex_conversion", 

41] 

42 

43 

44class HistoryEventDict(TypedDict): 

45 type: HistoryEventType 

46 pid: str 

47 col: "Collection | None" 

48 

49 source: NotRequired[str] 

50 unique_id: NotRequired[str] 

51 

52 parent_id: NotRequired[str] 

53 status: NotRequired["HistoryEventStatus"] 

54 title: NotRequired[str] 

55 userid: NotRequired[str] 

56 type_error: NotRequired[str] 

57 

58 created_on: NotRequired[datetime] 

59 message: NotRequired[str] 

60 

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

62 

63 

64class HistoryChildDict(TypedDict): 

65 resource: "Resource" 

66 type: str 

67 status: str 

68 status_message: NotRequired[str] 

69 message: NotRequired[str] 

70 score: NotRequired[int] 

71 "Matching score for an item" 

72 url: NotRequired[str] 

73 "Matching url of the remote resource"