File size: 842 Bytes
04a30fc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import pytest
from unittest.mock import Mock

from substra_launcher import launch_substra_space


class TestSubstraLauncher:

    @pytest.fixture
    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}"