Ejemplo n.º 1
0
 def _test_invalid(self, param, value, expected_log_message, mocked_error):
     """Tests that |expected_log_message| is logged as an error when config
     |param| is |value| which is invalid."""
     # Don't parameterize this function, it would be too messsy.
     self.config[param] = value
     with mock.patch('common.yaml_utils.read') as mocked_read_yaml:
         mocked_read_yaml.return_value = self.config
         with pytest.raises(run_experiment.ValidationError):
             run_experiment.read_and_validate_experiment_config(
                 'config_file')
     mocked_error.assert_called_with(expected_log_message, param, str(value))
Ejemplo n.º 2
0
 def test_missing_required_cloud(self, mocked_error):
     """Tests that an error is logged when the config file is missing a
     required cloudconfig parameter."""
     # All but cloud_compute_zone.
     del self.config['cloud_compute_zone']
     with mock.patch('common.yaml_utils.read') as mocked_read_yaml:
         mocked_read_yaml.return_value = self.config
         with pytest.raises(run_experiment.ValidationError):
             run_experiment.read_and_validate_experiment_config(
                 'config_file')
         mocked_error.assert_called_with('Config does not contain "%s".',
                                         'cloud_compute_zone')
Ejemplo n.º 3
0
 def test_multiple_invalid(self, mocked_error):
     """Test that multiple errors are logged when multiple parameters are
     invalid."""
     self.config['experiment_filestore'] = 1
     self.config['report_filestore'] = None
     with mock.patch('common.yaml_utils.read') as mocked_read_yaml:
         mocked_read_yaml.return_value = self.config
         with pytest.raises(run_experiment.ValidationError):
             run_experiment.read_and_validate_experiment_config(
                 'config_file')
     mocked_error.assert_any_call(
         'Config parameter "%s" is "%s". It must be a lowercase string.',
         'experiment_filestore', str(self.config['experiment_filestore']))
     mocked_error.assert_any_call(
         'Config parameter "%s" is "%s". It must be a lowercase string.',
         'report_filestore', str(self.config['report_filestore']))
Ejemplo n.º 4
0
 def test_multiple_invalid(self, mocked_error):
     """Test that multiple errors are logged when multiple parameters are
     invalid."""
     self.config['cloud_experiment_bucket'] = 1
     self.config['cloud_web_bucket'] = None
     with mock.patch('common.yaml_utils.read') as mocked_read_yaml:
         mocked_read_yaml.side_effect = lambda config_filename: self.config
         with pytest.raises(run_experiment.ValidationError):
             run_experiment.read_and_validate_experiment_config(
                 'config_file')
     mocked_error.assert_any_call(
         'Config parameter "%s" is "%s". It must be a lowercase string.',
         'cloud_experiment_bucket',
         str(self.config['cloud_experiment_bucket']))
     mocked_error.assert_any_call(
         'Config parameter "%s" is "%s". It must be a lowercase string.',
         'cloud_web_bucket', str(self.config['cloud_web_bucket']))