From f4a79308acf35642051d50b14106851b8cc00f57 Mon Sep 17 00:00:00 2001 From: IAlibay Date: Wed, 18 Sep 2024 03:05:43 +0100 Subject: [PATCH] Add test for the error return --- openfe/protocols/openmm_rfe/equil_rfe_methods.py | 9 +++++---- .../protocols/test_openmm_equil_rfe_protocols.py | 12 ++++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/openfe/protocols/openmm_rfe/equil_rfe_methods.py b/openfe/protocols/openmm_rfe/equil_rfe_methods.py index bc8aba4cc..ae3f19619 100644 --- a/openfe/protocols/openmm_rfe/equil_rfe_methods.py +++ b/openfe/protocols/openmm_rfe/equil_rfe_methods.py @@ -1101,10 +1101,11 @@ def structural_analysis(scratch, shared) -> dict: analysis_out = scratch / 'structural_analysis.json' ret = subprocess.run( - ['openfe_analysis', # CLI entry point - 'RFE_analysis', # CLI option - str(shared), # Where the simulation.nc fille - str(analysis_out) # Where the analysis json file is written + [ + 'openfe_analysis', # CLI entry point + 'RFE_analysis', # CLI option + str(shared), # Where the simulation.nc fille + str(analysis_out) # Where the analysis json file is written ], stdout=subprocess.PIPE, stderr=subprocess.PIPE diff --git a/openfe/tests/protocols/test_openmm_equil_rfe_protocols.py b/openfe/tests/protocols/test_openmm_equil_rfe_protocols.py index a16788e51..a0dcb3b66 100644 --- a/openfe/tests/protocols/test_openmm_equil_rfe_protocols.py +++ b/openfe/tests/protocols/test_openmm_equil_rfe_protocols.py @@ -10,6 +10,7 @@ from importlib import resources from unittest import mock import sys +from pathlib import Path import mdtraj as mdt import pytest @@ -2103,3 +2104,14 @@ def test_dry_run_complex_alchemwater_totcharge( assert len(htf._atom_classes['core_atoms']) == core_atoms assert len(htf._atom_classes['unique_new_atoms']) == new_uniq assert len(htf._atom_classes['unique_old_atoms']) == old_uniq + + +def test_structural_analysis_error(tmpdir): + + with tmpdir.as_cwd(): + ret = openmm_rfe.RelativeHybridTopologyProtocolUnit.structural_analysis( + Path('.'), Path('.') + ) + + assert 'structural_analysis_error' in ret + assert 'structural_analysis' not in ret