File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -507,7 +507,6 @@ async def _prep_document(
507
507
else :
508
508
# It's a regular file
509
509
logger .info (f"Fetching document from URL: { self .url } " )
510
- # document_data = await self._fetch_document()
511
510
if "application/pdf" in content_type :
512
511
extension = "pdf"
513
512
else :
Original file line number Diff line number Diff line change @@ -2478,3 +2478,25 @@ async def test_convert_url_non_200_response():
2478
2478
with patch (AIOHTTP_POST_PATH , return_value = mock_response ):
2479
2479
with pytest .raises (DjangoValidationError ):
2480
2480
await document ._convert_url_to_pdf ("https://example.com/doc.pdf" )
2481
+
2482
+
2483
+ async def test_fetch_document_200_response ():
2484
+ AIOHTTP_GET_PATH = "api.models.aiohttp.ClientSession.get"
2485
+
2486
+ # Mock response with non-200 status
2487
+ mock_response = AsyncMock ()
2488
+ mock_response .status = 200
2489
+ mock_response .headers = {
2490
+ "Content-Type" : "application/pdf" ,
2491
+ "Content-Disposition" : "" , # Empty content disposition
2492
+ "Content-Length" : "1000" ,
2493
+ }
2494
+ mock_response .__aenter__ .return_value = mock_response
2495
+
2496
+ document = Document (url = "https://examplepdf.com" )
2497
+
2498
+ with patch (AIOHTTP_GET_PATH , return_value = mock_response ):
2499
+ content_type , filename , data = await document ._fetch_document ()
2500
+
2501
+ assert content_type == "application/pdf"
2502
+ assert filename == "downloaded_file"
You can’t perform that action at this time.
0 commit comments