@@ -1709,3 +1709,104 @@ async def test_download_batch_transform_result_async(
17091709 sent_requests [1 ].headers [HEADER_USER_AGENT ]
17101710 == f"UiPath.Python.Sdk/UiPath.Python.Sdk.Activities.ContextGroundingService.download_batch_transform_result_async/{ version } "
17111711 )
1712+
1713+ def test_download_batch_transform_result_creates_nested_directories (
1714+ self ,
1715+ httpx_mock : HTTPXMock ,
1716+ service : ContextGroundingService ,
1717+ base_url : str ,
1718+ org : str ,
1719+ tenant : str ,
1720+ tmp_path ,
1721+ ) -> None :
1722+ httpx_mock .add_response (
1723+ url = f"{ base_url } { org } { tenant } /ecs_/v2/batchRag/test-batch-id" ,
1724+ status_code = 200 ,
1725+ json = {
1726+ "id" : "test-batch-id" ,
1727+ "name" : "test-batch-transform" ,
1728+ "lastBatchRagStatus" : "Successful" ,
1729+ "prompt" : "Summarize documents" ,
1730+ "targetFileGlobPattern" : "**" ,
1731+ "useWebSearchGrounding" : False ,
1732+ "outputColumns" : [
1733+ {"name" : "summary" , "description" : "Document summary" }
1734+ ],
1735+ "createdDate" : "2024-01-15T10:30:00Z" ,
1736+ },
1737+ )
1738+
1739+ httpx_mock .add_response (
1740+ url = f"{ base_url } { org } { tenant } /ecs_/v2/batchRag/test-batch-id/GetReadUri" ,
1741+ status_code = 200 ,
1742+ json = {
1743+ "uri" : "https://storage.example.com/result.csv" ,
1744+ },
1745+ )
1746+
1747+ httpx_mock .add_response (
1748+ url = "https://storage.example.com/result.csv" ,
1749+ status_code = 200 ,
1750+ content = b"col1,col2\n val1,val2" ,
1751+ )
1752+
1753+ destination = tmp_path / "output" / "nested" / "result.csv"
1754+ service .download_batch_transform_result (
1755+ id = "test-batch-id" ,
1756+ destination_path = str (destination ),
1757+ )
1758+
1759+ assert destination .exists ()
1760+ assert destination .read_bytes () == b"col1,col2\n val1,val2"
1761+ assert destination .parent .exists ()
1762+
1763+ @pytest .mark .anyio
1764+ async def test_download_batch_transform_result_async_creates_nested_directories (
1765+ self ,
1766+ httpx_mock : HTTPXMock ,
1767+ service : ContextGroundingService ,
1768+ base_url : str ,
1769+ org : str ,
1770+ tenant : str ,
1771+ tmp_path ,
1772+ ) -> None :
1773+ httpx_mock .add_response (
1774+ url = f"{ base_url } { org } { tenant } /ecs_/v2/batchRag/test-batch-id" ,
1775+ status_code = 200 ,
1776+ json = {
1777+ "id" : "test-batch-id" ,
1778+ "name" : "test-batch-transform" ,
1779+ "lastBatchRagStatus" : "Successful" ,
1780+ "prompt" : "Summarize documents" ,
1781+ "targetFileGlobPattern" : "**" ,
1782+ "useWebSearchGrounding" : False ,
1783+ "outputColumns" : [
1784+ {"name" : "summary" , "description" : "Document summary" }
1785+ ],
1786+ "createdDate" : "2024-01-15T10:30:00Z" ,
1787+ },
1788+ )
1789+
1790+ httpx_mock .add_response (
1791+ url = f"{ base_url } { org } { tenant } /ecs_/v2/batchRag/test-batch-id/GetReadUri" ,
1792+ status_code = 200 ,
1793+ json = {
1794+ "uri" : "https://storage.example.com/result.csv" ,
1795+ },
1796+ )
1797+
1798+ httpx_mock .add_response (
1799+ url = "https://storage.example.com/result.csv" ,
1800+ status_code = 200 ,
1801+ content = b"col1,col2\n val1,val2" ,
1802+ )
1803+
1804+ destination = tmp_path / "output" / "nested" / "result.csv"
1805+ await service .download_batch_transform_result_async (
1806+ id = "test-batch-id" ,
1807+ destination_path = str (destination ),
1808+ )
1809+
1810+ assert destination .exists ()
1811+ assert destination .read_bytes () == b"col1,col2\n val1,val2"
1812+ assert destination .parent .exists ()
0 commit comments