File size: 1,777 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
59
60
61
62
63
64
65
66
67
68
from pathlib import Path
from unittest import mock

from folding_studio.cli import app
from folding_studio.query import SoloSeqQuery
from typer.testing import CliRunner

current_workdir = Path(__file__).parent.resolve()
data_dir = Path(current_workdir / "data")

runner = CliRunner()


def test_predict_with_fasta_file_pass(
    mock_send_request: mock.Mock,
    mock_download_results: mock.Mock,
    tmp_files,
):
    result = runner.invoke(
        app,
        [
            "predict",
            "soloseq",
            str(tmp_files["monomer_fasta"]),
            "--output",
            tmp_files["output_dir"],
            "--project-code",
            "my_project_code",
        ],
    )
    assert result.exit_code == 0, result.output

    expected_query = SoloSeqQuery(
        fasta_files={"monomer": ">tag1|tag2\nABCDEGF"}, query_name="monomer"
    )
    mock_send_request.assert_called_once_with(expected_query, "my_project_code")
    mock_download_results.assert_called_once()


def test_predict_with_fasta_dir_pass(
    mock_send_request: mock.Mock,
    mock_download_results: mock.Mock,
    tmp_files,
):
    result = runner.invoke(
        app,
        [
            "predict",
            "soloseq",
            str(tmp_files["valid_dir"]),
            "--output",
            tmp_files["output_dir"],
            "--project-code",
            "my_project_code",
        ],
    )
    assert result.exit_code == 0, result.output

    expected_query = SoloSeqQuery(
        fasta_files={
            "monomer_1": ">tag1|tag2\nABCDEGF",
            "monomer_2": ">tag1|tag2\nABCDEGF",
        },
        query_name="valid_dir",
    )
    mock_send_request.assert_called_once_with(expected_query, "my_project_code")
    mock_download_results.assert_called_once()