Ejemplo n.º 1
0
    def test_main_help(self, script_runner: ScriptRunner) -> None:
        """Test help option.

        GIVEN the main command-line interface
        WHEN the '-h' or '--help' argument is provided
        THEN the help screen should appear

        Parameters
        ----------
        script_runner : ScriptRunner
            Command-line runner
        """
        result = script_runner.run(
            "qaa",
            "-h",
        )
        result2 = script_runner.run(
            "qaa",
            "--help",
        )

        assert "Usage:" in result.stdout
        assert result.success
        assert result.stdout == result2.stdout
Ejemplo n.º 2
0
def test_reindex(script_runner: ScriptRunner, asset_dir: Path,
                 reindex_data: Path, tmp_path: Path, docker_from: str):
    ret = script_runner.run('bldr', 'reindex', docker_from, '--local-repo-dir',
                            reindex_data)
    assert ret.success, "reindex command should be succeded"
    assert ret.stderr == '', "nothing should be written to stderr"

    expected_packages_content = asset_dir.joinpath(
        'test-reindex-data', 'Packages.correct').read_text()
    assert reindex_data.joinpath('Packages').read_text(
    ) == expected_packages_content, 'Generated Packages file should be identical to Packages.correct'

    expected_sources_content = asset_dir.joinpath(
        'test-reindex-data', 'Sources.correct').read_text()
    assert reindex_data.joinpath('Sources').read_text(
    ) == expected_sources_content, 'Generated Sources file should be identical to Sources.correct'
Ejemplo n.º 3
0
def test_command_help(script_runner: ScriptRunner):
    ret = script_runner.run('bldr', 'build', '--help')
    assert ret.success

    argument_list = [
        'docker_from',
        'package',
        '--snapshot',
        '--shell',
        '--deb-build-options',
        '--local-repo-dir',
        '--nocache',
        '--container-env',
        '--hooks-dir',
    ]
    for argument in argument_list:
        assert argument in ret.stdout
Ejemplo n.º 4
0
    def test_pca(self, script_runner: ScriptRunner, tmp_path: Path) -> None:
        """Test pca subcommand.

        GIVEN a trajectory file
        WHEN invoking the pca subcommand
        THEN an several files will be written

        Parameters
        ----------
        script_runner : ScriptRunner
            Command-line runner
        tmp_path : Path
            Temporary directory
        """
        logfile = tmp_path.joinpath("pca.log")
        result = script_runner.run(
            "qaa",
            "pca",
            "-s",
            TOPWW,
            "-f",
            TRJWW,
            "-o",
            tmp_path.as_posix(),
            "-l",
            logfile.as_posix(),
            "-m",
            "ca",
            "--verbose",
        )

        assert result.success
        assert logfile.exists()

        # Test whether text data file exists
        data = tmp_path.joinpath("projection.csv")
        assert data.exists()
        assert data.stat().st_size > 0

        # Test whether binary data file exists
        bin_data = tmp_path.joinpath("projection.npy")
        assert bin_data.exists()
        assert bin_data.stat().st_size > 0

        assert tmp_path.joinpath("explained_variance_ratio.png").exists()
Ejemplo n.º 5
0
    def test_help(self, script_runner: ScriptRunner) -> None:
        """Test help output.

        GIVEN the cluster subcommand
        WHEN the help option is invoked
        THEN the help output should be displayed

        Parameters
        ----------
        script_runner : ScriptRunner
            Command-line runner
        """
        result = script_runner.run(
            "qaa",
            "plot",
            "-h",
        )
        assert result.success
Ejemplo n.º 6
0
def test_failed_build(script_runner: ScriptRunner, asset_dir: Path,
                      docker_from: str, local_repo_dir: Path):
    ret = script_runner.run('bldr',
                            'build',
                            docker_from,
                            "--local-repo-dir",
                            str(local_repo_dir),
                            cwd=asset_dir.joinpath('never-builds'))
    assert not ret.success, "build command should be failed"
    assert ret.stderr == '', "nothing should be written to stderr"

    assert local_repo_dir.joinpath(
        "Packages").is_file(), "Packages file should exist"
    assert local_repo_dir.joinpath(
        "Sources").is_file(), "Sources file should exist"
    assert local_repo_dir.joinpath(
        "Packages").stat().st_size == 0, "Packages file should be empty"
    assert local_repo_dir.joinpath(
        "Sources").stat().st_size == 0, "Sources file should be empty"
Ejemplo n.º 7
0
def test_graph_parser(
    train_config: pathlib.Path,
    treebank: pathlib.Path,
    script_runner: pytest_console_scripts.ScriptRunner,
    tmp_path: pathlib.Path,
):
    ret = script_runner.run(
        "graph_parser",
        str(train_config),
        "--train_file",
        str(treebank),
        "--dev_file",
        str(treebank),
        "--pred_file",
        str(treebank),
        "--out_dir",
        str(tmp_path),
    )
    assert ret.success
Ejemplo n.º 8
0
def test_build(script_runner: ScriptRunner, asset_dir: Path, docker_from: str,
               local_repo_dir: Path):
    ret = script_runner.run('bldr',
                            'build',
                            docker_from,
                            "--local-repo-dir",
                            str(local_repo_dir),
                            cwd=asset_dir.joinpath('example-lang-C'))
    assert ret.success, "build command should be succeded"
    assert 'Your deb files are at' in ret.stdout
    assert ret.stderr == '', "nothing should be written to stderr"

    assert local_repo_dir.joinpath(
        "Packages").is_file(), "Packages file should exist"
    assert local_repo_dir.joinpath(
        "Sources").is_file(), "Packages file should exist"
    assert local_repo_dir.joinpath(
        "Packages").stat().st_size > 0, "Packages file should be non-empty"
    assert local_repo_dir.joinpath(
        "Sources").stat().st_size > 0, "Sources file should be non-empty"
Ejemplo n.º 9
0
    def test_cluster_npy(self, script_runner: ScriptRunner,
                         tmp_path: Path) -> None:
        """Test plot subcommand with binary NumPy input file.

        GIVEN a data file
        WHEN invoking the plot subcommand with cluster option
        THEN saves a plotted image to disk

        Parameters
        ----------
        script_runner : ScriptRunner
            Command-line runner
        tmp_path : Path
            Temporary directory
        """
        outfile = tmp_path.joinpath("pca-cluster.png")
        logfile = tmp_path.joinpath("plot.log")
        result = script_runner.run(
            "qaa",
            "plot",
            "-i",
            CLUSTNPY,
            "-c",
            CENTNPY,
            "--label",
            LABELS,
            "-o",
            outfile.as_posix(),
            "-l",
            logfile.as_posix(),
            "--pca",
            "--cluster",
            "--verbose",
        )
        assert result.success
        assert logfile.exists()
        assert outfile.exists()
        assert outfile.stat().st_size > 0
Ejemplo n.º 10
0
    def test_cluster_save(self, script_runner: ScriptRunner,
                          tmp_path: Path) -> None:
        """Test save option.

        GIVEN trajectory, topology and data files
        WHEN the '--save' option is provided
        THEN PDB files will be saved

        Parameters
        ----------
        script_runner : ScriptRunner
            Command-line runner
        tmp_path : Path
            Temporary directory
        """
        logfile = tmp_path.joinpath("cluster.log")
        result = script_runner.run(
            "qaa",
            "cluster",
            "-s",
            TOPWW,
            "-f",
            TRJWW,
            "-i",
            PROJ,
            "-o",
            tmp_path.as_posix(),
            "-l",
            logfile.as_posix(),
            "--pca",
            "--save",
            "--verbose",
        )
        assert result.success
        assert logfile.exists()
        assert len(tuple(tmp_path.glob("*.pdb"))) == 3
Ejemplo n.º 11
0
    def test_align_verbose(self, script_runner: ScriptRunner,
                           tmp_path: Path) -> None:
        """Test align subcommand with verbose option.

        GIVEN a trajectory file
        WHEN invoking the align subcommand
        THEN an aligned trajectory and average structure file will be written

        Parameters
        ----------
        script_runner : ScriptRunner
            Command-line runner
        tmp_path : Path
            Temporary directory
        """
        logfile = tmp_path.joinpath("align.log")
        result = script_runner.run(
            "qaa",
            "align",
            "-s",
            TOPWW,
            "-f",
            TRJWW,
            "-r",
            tmp_path.joinpath("average.pdb").as_posix(),
            "-o",
            tmp_path.joinpath("align.nc").as_posix(),
            "-l",
            logfile.as_posix(),
            "-m",
            "ca",
            "--verbose",
        )

        assert result.success
        assert logfile.exists()
Ejemplo n.º 12
0
def test_command_names_in_help(script_runner: ScriptRunner):
    ret = script_runner.run('bldr', '--help')
    assert ret.success
    for command_name in ['build', 'shell', 'reindex', 'selftest']:
        assert command_name in ret.stdout
Ejemplo n.º 13
0
def test_version(script_runner: ScriptRunner):
    ret = script_runner.run('bldr', '--version')
    assert ret.success, "version print should be succeded"
    assert ret.stdout == 'bldr {}\n'.format(get_version())
    assert ret.stderr == '', "nothing should be written to stderr"
Ejemplo n.º 14
0
def test_selftest(script_runner: ScriptRunner):
    ret = script_runner.run('bldr', 'selftest')
    assert ret.success, "selftest command should be succeded"
    assert ret.stderr == '', "nothing should be written to stderr"
Ejemplo n.º 15
0
 def test_no_arguments(self, script_runner: ScriptRunner):
     args = ["stac-client"]
     result = script_runner.run(*args, print_result=False)
     assert result.success