@@ -359,6 +359,75 @@ def test_run_entropy_workflow(self):
359359 )
360360 mock_entropy_manager .execute .assert_called_once ()
361361
362+ def test_run_entropy_workflow_with_forcefile (self ):
363+ """
364+ Test the else-branch in run_entropy_workflow where forcefile is not None.
365+ """
366+ run_manager = RunManager ("mock_folder/job001" )
367+ run_manager ._logging_config = MagicMock ()
368+ run_manager ._config_manager = MagicMock ()
369+ run_manager .load_citation_data = MagicMock ()
370+ run_manager .show_splash = MagicMock ()
371+ run_manager ._data_logger = MagicMock ()
372+ run_manager .folder = self .test_dir
373+
374+ # Logger mock
375+ mock_logger = MagicMock ()
376+ run_manager ._logging_config .setup_logging .return_value = mock_logger
377+
378+ # Config contains force_file
379+ run_manager ._config_manager .load_config .return_value = {
380+ "test_run" : {
381+ "top_traj_file" : ["/path/to/tpr" , "/path/to/trr" ],
382+ "force_file" : "/path/to/forces" ,
383+ "file_format" : "gro" ,
384+ "kcal_force_units" : "kcal" ,
385+ "selection_string" : "all" ,
386+ "output_file" : "output.json" ,
387+ "verbose" : False ,
388+ }
389+ }
390+
391+ # Parse args mock
392+ mock_args = MagicMock ()
393+ mock_args .output_file = "output.json"
394+ mock_args .verbose = False
395+ mock_args .top_traj_file = ["/path/to/tpr" , "/path/to/trr" ]
396+ mock_args .force_file = "/path/to/forces"
397+ mock_args .file_format = "gro"
398+ mock_args .kcal_force_units = "kcal"
399+ mock_args .selection_string = "all"
400+
401+ parser = run_manager ._config_manager .setup_argparse .return_value
402+ parser .parse_known_args .return_value = (mock_args , [])
403+ run_manager ._config_manager .merge_configs .return_value = mock_args
404+
405+ # Mock UniverseOperations.merge_forces
406+ with (
407+ unittest .mock .patch (
408+ "CodeEntropy.run.EntropyManager" , return_value = MagicMock ()
409+ ) as Entropy_patch ,
410+ unittest .mock .patch ("CodeEntropy.run.UniverseOperations" ) as UOps_patch ,
411+ unittest .mock .patch ("CodeEntropy.run.mda.Universe" ) as mock_universe ,
412+ ):
413+ mock_universe_ops = UOps_patch .return_value
414+ mock_universe_ops .merge_forces .return_value = MagicMock ()
415+
416+ run_manager .run_entropy_workflow ()
417+
418+ # Ensure merge_forces is used
419+ mock_universe_ops .merge_forces .assert_called_once_with (
420+ "/path/to/tpr" ,
421+ ["/path/to/trr" ],
422+ "/path/to/forces" ,
423+ "gro" ,
424+ "kcal" ,
425+ )
426+
427+ mock_universe .assert_not_called ()
428+
429+ Entropy_patch .return_value .execute .assert_called_once ()
430+
362431 def test_run_configuration_warning (self ):
363432 """
364433 Test that a warning is logged when the config entry is not a dictionary.
0 commit comments