Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal download API: Add proper validated directory input #4981

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
avoid 'mock_directory'
use temp dir to avoid accidental fs pollution from tests
  • Loading branch information
mcmonkey4eva committed Sep 23, 2024
commit 89b3539dd6f96086f635716fb47f6a5fa3805010
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
Loading