Coverage for src / local_deep_research / storage / base.py: 72%

18 statements  

« prev     ^ index     » next       coverage.py v7.12.0, created at 2026-01-11 00:51 +0000

1"""Base interface for report storage backends.""" 

2 

3from abc import ABC, abstractmethod 

4from typing import Dict, Any, Optional 

5 

6 

7class ReportStorage(ABC): 

8 """Abstract base class for report storage backends.""" 

9 

10 @abstractmethod 

11 def save_report( 

12 self, 

13 research_id: str, 

14 content: str, 

15 metadata: Optional[Dict[str, Any]] = None, 

16 username: Optional[str] = None, 

17 ) -> bool: 

18 """Save a research report. 

19 

20 Args: 

21 research_id: Unique identifier for the research 

22 content: Report content (markdown) 

23 metadata: Optional metadata to store with the report 

24 username: Optional username for user-specific storage 

25 

26 Returns: 

27 True if successful, False otherwise 

28 """ 

29 pass 

30 

31 @abstractmethod 

32 def get_report( 

33 self, research_id: str, username: Optional[str] = None 

34 ) -> Optional[str]: 

35 """Retrieve a research report. 

36 

37 Args: 

38 research_id: Unique identifier for the research 

39 username: Optional username for user-specific storage 

40 

41 Returns: 

42 Report content if found, None otherwise 

43 """ 

44 pass 

45 

46 @abstractmethod 

47 def get_report_with_metadata( 

48 self, research_id: str, username: Optional[str] = None 

49 ) -> Optional[Dict[str, Any]]: 

50 """Retrieve a research report with its metadata. 

51 

52 Args: 

53 research_id: Unique identifier for the research 

54 username: Optional username for user-specific storage 

55 

56 Returns: 

57 Dictionary with 'content' and 'metadata' keys if found, None otherwise 

58 """ 

59 pass 

60 

61 @abstractmethod 

62 def delete_report( 

63 self, research_id: str, username: Optional[str] = None 

64 ) -> bool: 

65 """Delete a research report. 

66 

67 Args: 

68 research_id: Unique identifier for the research 

69 username: Optional username for user-specific storage 

70 

71 Returns: 

72 True if successful, False otherwise 

73 """ 

74 pass 

75 

76 @abstractmethod 

77 def report_exists( 

78 self, research_id: str, username: Optional[str] = None 

79 ) -> bool: 

80 """Check if a report exists. 

81 

82 Args: 

83 research_id: Unique identifier for the research 

84 username: Optional username for user-specific storage 

85 

86 Returns: 

87 True if report exists, False otherwise 

88 """ 

89 pass