Skip to content

Commit

Permalink
avoid 'mock_directory'
Browse files Browse the repository at this point in the history
use temp dir to avoid accidental fs pollution from tests
  • Loading branch information
mcmonkey4eva committed Sep 23, 2024
1 parent ae931da commit 89b3539
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions tests-unit/prompt_server_test/download_models_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,27 +109,26 @@ async def test_download_model_success(temp_dir):
mock_make_request.assert_called_once_with('http://example.com/model.sft')

@pytest.mark.asyncio
async def test_download_model_url_request_failure():
async def test_download_model_url_request_failure(temp_dir):
# Mock dependencies
mock_response = AsyncMock(spec=ClientResponse)
mock_response.status = 404 # Simulate a "Not Found" error
mock_get = AsyncMock(return_value=mock_response)
mock_progress_callback = AsyncMock()

fake_paths = {'checkpoints': (['mock_directory'], folder_paths.supported_pt_extensions)}
fake_paths = {'checkpoints': ([temp_dir], folder_paths.supported_pt_extensions)}

# Mock the create_model_path function
with patch('model_filemanager.create_model_path', return_value='/mock/path/model.safetensors'), \
patch('model_filemanager.check_file_exists', return_value=None), \
patch('folder_paths.get_folder_paths', return_value=['mock_directory']), \
patch('folder_paths.folder_names_and_paths', fake_paths):
# Call the function
result = await download_model(
mock_get,
'model.safetensors',
'http://example.com/model.safetensors',
'checkpoints',
'mock_directory',
temp_dir,
mock_progress_callback
)

Expand Down

0 comments on commit 89b3539

Please sign in to comment.