@@ -494,6 +494,103 @@ def test_empty_yaml_config(self, mock_exists, mock_file):
494494 self .assertIsInstance (config , dict )
495495 self .assertEqual (config , {})
496496
497+ def test_input_parameters_validation_all_valid (self ):
498+ """Test that input_parameters_validation passes with all valid inputs."""
499+ manager = ConfigManager ()
500+ u = MagicMock ()
501+ u .trajectory = [0 ] * 100
502+
503+ args = MagicMock (
504+ start = 10 ,
505+ end = 90 ,
506+ step = 1 ,
507+ bin_width = 30 ,
508+ temperature = 298.0 ,
509+ force_partitioning = 0.5 ,
510+ )
511+
512+ with patch .dict (
513+ "CodeEntropy.config.arg_config_manager.arg_map" ,
514+ {"force_partitioning" : {"default" : 0.5 }},
515+ ):
516+ manager .input_parameters_validation (u , args )
517+
518+ def test_check_input_start_valid (self ):
519+ """Test that a valid 'start' value does not raise an error."""
520+ args = MagicMock (start = 50 )
521+ u = MagicMock ()
522+ u .trajectory = [0 ] * 100
523+ ConfigManager ()._check_input_start (u , args )
524+
525+ def test_check_input_start_invalid (self ):
526+ """Test that an invalid 'start' value raises a ValueError."""
527+ args = MagicMock (start = 150 )
528+ u = MagicMock ()
529+ u .trajectory = [0 ] * 100
530+ with self .assertRaises (ValueError ):
531+ ConfigManager ()._check_input_start (u , args )
532+
533+ def test_check_input_end_valid (self ):
534+ """Test that a valid 'end' value does not raise an error."""
535+ args = MagicMock (end = 100 )
536+ u = MagicMock ()
537+ u .trajectory = [0 ] * 100
538+ ConfigManager ()._check_input_end (u , args )
539+
540+ def test_check_input_end_invalid (self ):
541+ """Test that an 'end' value exceeding trajectory length raises a ValueError."""
542+ args = MagicMock (end = 101 )
543+ u = MagicMock ()
544+ u .trajectory = [0 ] * 100
545+ with self .assertRaises (ValueError ):
546+ ConfigManager ()._check_input_end (u , args )
547+
548+ @patch ("CodeEntropy.config.arg_config_manager.logger" )
549+ def test_check_input_step_negative (self , mock_logger ):
550+ """Test that a negative 'step' value triggers a warning."""
551+ args = MagicMock (step = - 1 )
552+ ConfigManager ()._check_input_step (args )
553+ mock_logger .warning .assert_called_once ()
554+
555+ def test_check_input_bin_width_valid (self ):
556+ """Test that a valid 'bin_width' value does not raise an error."""
557+ args = MagicMock (bin_width = 180 )
558+ ConfigManager ()._check_input_bin_width (args )
559+
560+ def test_check_input_bin_width_invalid_low (self ):
561+ """Test that a negative 'bin_width' value raises a ValueError."""
562+ args = MagicMock (bin_width = - 10 )
563+ with self .assertRaises (ValueError ):
564+ ConfigManager ()._check_input_bin_width (args )
565+
566+ def test_check_input_bin_width_invalid_high (self ):
567+ """Test that a 'bin_width' value above 360 raises a ValueError."""
568+ args = MagicMock (bin_width = 400 )
569+ with self .assertRaises (ValueError ):
570+ ConfigManager ()._check_input_bin_width (args )
571+
572+ def test_check_input_temperature_valid (self ):
573+ """Test that a valid 'temperature' value does not raise an error."""
574+ args = MagicMock (temperature = 298.0 )
575+ ConfigManager ()._check_input_temperature (args )
576+
577+ def test_check_input_temperature_invalid (self ):
578+ """Test that a negative 'temperature' value raises a ValueError."""
579+ args = MagicMock (temperature = - 5 )
580+ with self .assertRaises (ValueError ):
581+ ConfigManager ()._check_input_temperature (args )
582+
583+ @patch ("CodeEntropy.config.arg_config_manager.logger" )
584+ def test_check_input_force_partitioning_warning (self , mock_logger ):
585+ """Test that a non-default 'force_partitioning' value triggers a warning."""
586+ args = MagicMock (force_partitioning = 0.7 )
587+ with patch .dict (
588+ "CodeEntropy.config.arg_config_manager.arg_map" ,
589+ {"force_partitioning" : {"default" : 0.5 }},
590+ ):
591+ ConfigManager ()._check_input_force_partitioning (args )
592+ mock_logger .warning .assert_called_once ()
593+
497594
498595if __name__ == "__main__" :
499596 unittest .main ()
0 commit comments