Spaces:
Runtime error
Runtime error
import pytest | |
from unittest.mock import Mock | |
from substra_launcher import launch_substra_space | |
class TestSubstraLauncher: | |
def mock_hf_api(self): | |
mock_hf_api = Mock() | |
mock_hf_api.create_repo = Mock(side_effect=lambda repo_id, *args, **kwargs: f"https://hf.space/{repo_id}") | |
return mock_hf_api | |
def test_launch_substra_space(self, mock_hf_api): | |
repo_id = "user/space" | |
repo_link = launch_substra_space(mock_hf_api, repo_id=repo_id) | |
mock_hf_api.create_repo.assert_called_once_with( | |
repo_id=repo_id, repo_type="space", space_sdk="docker" | |
) | |
mock_hf_api.upload_folder.assert_called_once_with( | |
repo_id=repo_id, repo_type="space", folder_path="substra_template/" | |
) | |
assert repo_link == f"https://hf.space/{repo_id}" |