File size: 1,384 Bytes
44459bb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
"""Test simple msa."""

from pathlib import Path
from unittest import mock

import pytest
from folding_studio.api_call.msa import simple_msa
from folding_studio.config import API_URL, REQUEST_TIMEOUT
from folding_studio.utils.data_model import MSARequestParams


@pytest.fixture(autouse=True)
def mock_post():
    post_mock = mock.Mock()
    mock_response = mock.MagicMock()
    mock_response.ok = True
    post_mock.return_value = mock_response
    with mock.patch("requests.post", post_mock):
        yield post_mock


@pytest.fixture(autouse=True)
def mock_get_auth_headers():
    with mock.patch(
        "folding_studio.api_call.msa.get_auth_headers",
        return_value={"Authorization": "Bearer identity_token"},
    ) as m:
        yield m


def test_simple_msa_pass(
    tmp_path: Path, mock_post: pytest.FixtureRequest, headers: dict[str, str]
):
    """Test simple msa pass."""

    file = tmp_path / "fasta_file.fasta"
    file.touch()

    params = MSARequestParams(
        ignore_cache=False,
        msa_mode="search",
    )

    simple_msa(
        file,
        params,
        project_code="FOLDING_DEV",
    )

    mock_post.assert_called_once_with(
        API_URL + "searchMSA",
        data=params.model_dump(mode="json"),
        headers=headers,
        files=mock.ANY,
        timeout=REQUEST_TIMEOUT,
        params={"project_code": "FOLDING_DEV"},
    )