def test_main_output(self, capsys): """Test main with user defined output name.""" args = self.args.copy() args["out_file"] = "text.txt" UI.main(**args) captured = capsys.readouterr().out assert "Results written to text.txt" in captured
def test_main_subdef(self, capsys): """Test main with partial def file.""" args = self.args.copy() args["def_file"] = str(PATH_DATA / "OP_def_HP_BergerPOPC.def") UI.main(**args) captured = capsys.readouterr().out assert self.stdout_output in captured
def test_main_traj(self, capsys): """Test main with trajectory.""" args = self.args.copy() args["traj_file"] = str(PATH_DATA / "2POPC.xtc") UI.main(**args) captured = capsys.readouterr().out assert self.stdout_output in captured assert "Dealing with frame 10 at 10000.0 ps." in captured
def test_fail_main_coord_def_mismatch(self): """Test when coord file and def file doesn't match.""" args = self.args.copy() args["def_file"] = str(PATH_DATA / "op_wrong1.def") with pytest.raises(BuildHError) as err: UI.main(**args) assert f"Atoms defined in {args['def_file']} are missing in the structure" in str( err.value)
def test_fail_main_subdef_traj(self, ): """Test main with partial def file and a output trajectory. Must fail.""" args = self.args.copy() args["def_file"] = str(PATH_DATA / "OP_def_HP_BergerPOPC.def") args["traj_file"] = str(PATH_DATA / "2POPC.xtc") args["prefix_traj_ouput"] = "test" with pytest.raises(BuildHError) as err: UI.main(**args) assert "Error on the number of H's to rebuild" in str(err.value)
def test_main_traj_output(self, capsys): """Test main with trajectory and output trajectory.""" args = self.args.copy() args["traj_file"] = str(PATH_DATA / "2POPC.xtc") args["prefix_traj_ouput"] = "test" UI.main(**args) captured = capsys.readouterr().out assert self.stdout_output in captured assert "Writing new pdb with hydrogens." in captured assert "Writing trajectory with hydrogens in xtc file." in captured
def test_main_traj_slice(self, capsys): """Test main with sliced trajectory.""" args = self.args.copy() args["traj_file"] = str(PATH_DATA / "2POPC.xtc") args["end"] = 3000 UI.main(**args) captured = capsys.readouterr().out assert self.stdout_output in captured assert "Dealing with frame 3 at 3000.0 ps." in captured # Make sure we stop at frame 3 assert "Dealing with frame 10 at 10000.0 ps." not in captured
def test_fail_main_coord_topology_mismatch(self): """Test when coord file and topology doesn't match.""" args = self.args.copy() lipids_tops = lipids.read_lipids_topH( [lipids.PATH_JSON / "CHARMM36_POPC.json"]) dic_lipid = lipids_tops["CHARMM36_POPC"] args["dic_lipid"] = dic_lipid with pytest.raises(BuildHError) as err: UI.main(**args) assert "The topology chosen does not match the structure provided" in str( err.value)
def test_main_minimal(self, capsys): """Test main with minimal arguments.""" UI.main(**self.args) captured = capsys.readouterr().out assert self.stdout_output in captured