File size: 1,302 Bytes
5631464
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Test preprocessing client."""
import os
from pathlib import Path

import pytest

from haddock.clis.cli_pp import ap, main

from . import broken_pdb, corrected_pdb


def test_pp_cli():
    """
    Test `haddock-pp` client with broken PDB.

    This is the same PDB used to test the preprocessing library.
    """
    main(broken_pdb)
    output = Path(Path.cwd(), 'broken_processed.pdb')
    assert output.exists()

    result = output.read_text().strip(os.linesep)
    expected = corrected_pdb.read_text().strip(os.linesep)
    assert result == expected

    output.unlink()


@pytest.mark.parametrize(
    "arg,key,value",
    [
        ('-d', "dry", True),
        ('--dry', "dry", True),
        ('-t file1.top file2.top', "topfile", ['file1.top', 'file2.top']),
        ('--topfile file1.top file2.top', "topfile", ['file1.top', 'file2.top']),  # noqa: E501
        ('-s somesuffix', 'suffix', 'somesuffix'),
        ('--suffix somesuffix', 'suffix', 'somesuffix'),
        ('-odir somedir', 'output_directory', Path('somedir')),
        ('--output-directory somedir', 'output_directory', Path('somedir')),
        ]
    )
def test_cli_args(arg, key, value):
    """Test adding arguments to client."""
    cmd = ap.parse_args(('some-file.pdb ' + arg).split())
    assert value == vars(cmd)[key]