Coverage for src/qdrant_loader/connectors/shared/attachments/reader.py: 64%

14 statements  

« prev     ^ index     » next       coverage.py v7.10.6, created at 2025-09-08 06:05 +0000

1from __future__ import annotations 

2 

3import requests 

4 

5from qdrant_loader.core.attachment_downloader import ( 

6 AttachmentDownloader, 

7 AttachmentMetadata, 

8) 

9from qdrant_loader.core.document import Document 

10 

11 

12class AttachmentReader: 

13 """Facade around `AttachmentDownloader` for uniform usage in connectors.""" 

14 

15 def __init__( 

16 self, 

17 session: requests.Session, 

18 downloader: AttachmentDownloader, 

19 ) -> None: 

20 self.session = session 

21 self.downloader = downloader 

22 

23 async def fetch_and_process( 

24 self, attachments: list[AttachmentMetadata], parent: Document 

25 ) -> list[Document]: 

26 return await self.downloader.download_and_process_attachments( 

27 attachments, parent 

28 ) 

29 

30 # Optional cleanup hooks to allow connectors to close resources when reconfiguring 

31 async def aclose(self) -> None: # noqa: D401 - simple cleanup hook 

32 """Asynchronous cleanup for compatibility; currently no async resources.""" 

33 # If downloader/session expose explicit async cleanup in the future, call here 

34 return None 

35 

36 def close(self) -> None: # noqa: D401 - simple cleanup hook 

37 """Synchronous cleanup for compatibility; currently no resources to close.""" 

38 # requests.Session is owned by the connector, not by the reader 

39 return None