def test_cli_multiple_smiles( mocker, add_cli_arguments, tmpdir, shared_datadir, capsys, create_dummy_smiles_source, ): finder_patch = mocker.patch( "aizynthfinder.interfaces.aizynthcli.AiZynthFinder") finder_patch.return_value.extract_statistics.return_value = { "a": 1, "b": 2, "is_solved": True, } finder_patch.return_value.tree_search.return_value = 1.5 pd_patch = mocker.patch( "aizynthfinder.interfaces.aizynthcli.pd.DataFrame.from_dict") smiles_input = create_dummy_smiles_source("txt") output_name = str(tmpdir / "data.hdf5") add_cli_arguments( f"--smiles {smiles_input} --config config_local.yml --output {output_name}" ) cli_main() finder_patch.assert_called_with(configfile="config_local.yml") pd_patch.assert_called_once() output = capsys.readouterr() assert output.out.count("Done with") == 4 assert f"Output saved to {output_name}" in output.out
def test_cli_single_smiles(mocker, add_cli_arguments, tmpdir, capsys): finder_patch = mocker.patch("aizynthfinder.interfaces.aizynthcli.AiZynthFinder") finder_patch.return_value.extract_statistics.return_value = {"a": 1, "b": 2} json_patch = mocker.patch("aizynthfinder.interfaces.aizynthcli.json.dump") output_name = str(tmpdir / "trees.json") add_cli_arguments("--smiles COO --config config_local.yml --output " + output_name) cli_main() finder_patch.assert_called_with(configfile="config_local.yml") json_patch.assert_called_once() output = capsys.readouterr() assert f"Trees saved to {output_name}" in output.out assert "Scores for best routes" in output.out assert "a: 1" in output.out assert "b: 2" in output.out