11from urllib .parse import urljoin
22import aiohttp
33import pytest
4+ from rich .progress import Progress
45from dvuploader .directupload import (
56 _add_file_to_ds ,
67 UPLOAD_ENDPOINT ,
@@ -25,15 +26,23 @@ async def test_successfully_add_file_with_valid_filepath(self, mocker):
2526 pid = "persistent_id"
2627 fpath = "tests/fixtures/add_dir_files/somefile.txt"
2728 file = File (filepath = fpath )
29+ progress = Progress ()
30+ pbar = progress .add_task ("Uploading" , total = 1 )
2831
2932 # Invoke the function
30- result = await _add_file_to_ds (session , dataverse_url , pid , file )
33+ result = await _add_file_to_ds (
34+ session = session ,
35+ dataverse_url = dataverse_url ,
36+ pid = pid ,
37+ file = file ,
38+ progress = progress ,
39+ pbar = pbar ,
40+ )
3141
3242 # Assert that the response status is 200 and the result is True
3343 assert mock_post .called_with (
3444 urljoin (dataverse_url , UPLOAD_ENDPOINT + pid ), data = mocker .ANY
3545 )
36- assert result is True
3746
3847 @pytest .mark .asyncio
3948 async def test_successfully_replace_file_with_valid_filepath (self , mocker ):
@@ -47,16 +56,24 @@ async def test_successfully_replace_file_with_valid_filepath(self, mocker):
4756 pid = "persistent_id"
4857 fpath = "tests/fixtures/add_dir_files/somefile.txt"
4958 file = File (filepath = fpath , file_id = "0" )
59+ progress = Progress ()
60+ pbar = progress .add_task ("Uploading" , total = 1 )
5061
5162 # Invoke the function
52- result = await _add_file_to_ds (session , dataverse_url , pid , file )
63+ result = await _add_file_to_ds (
64+ session = session ,
65+ dataverse_url = dataverse_url ,
66+ pid = pid ,
67+ file = file ,
68+ progress = progress ,
69+ pbar = pbar ,
70+ )
5371
5472 # Assert that the response status is 200 and the result is True
5573 assert mock_post .called_with (
5674 urljoin (dataverse_url , REPLACE_ENDPOINT .format (FILE_ID = file .file_id )),
5775 data = mocker .ANY ,
5876 )
59- assert result is True
6077
6178
6279class Test_ValidateTicketResponse :
0 commit comments