def test_config_with_background_task(self): config = ClusterRunnerConfig(self._BACKGROUND_TASK_CONFIG) job_config = config.get_job_config() self.assertEqual( job_config.setup_build, 'echo "in the background" & echo "in the foreground" && echo "another thing" ' )
def job_config(self): """ Return the job config found in this project_type and matching any job_name parameter passed in :rtype: JobConfig """ config = ClusterRunnerConfig(self._get_config_contents()) return config.get_job_config(self._job_name)
def job_config(self): """ Return the job config found in this project_type and matching any job_name parameter passed in :rtype: JobConfig """ config = ClusterRunnerConfig(self._get_config_contents()) return config.get_job_config(self._job_name)
def test_undefined_conf_properties_return_default_values(self, conf_method_name, expected_value): config = ClusterRunnerConfig(self._MINIMAL_CONFIG) job_config = config.get_job_config() actual_value = getattr(job_config, conf_method_name) self.assertEqual(actual_value, expected_value, 'The default output of {}() should match the expected value.'.format(conf_method_name))
def test_valid_configs_are_detected(self, config_contents, is_expected_valid): config = ClusterRunnerConfig(config_contents) try: config.get_job_config() except (ConfigParseError, ConfigValidationError) as e: self.assertFalse(is_expected_valid, 'Config is valid, but threw {}'.format(type(e))) return self.assertTrue(is_expected_valid, 'Config is not valid, but parsed without error')
def test_all_conf_properties_are_correctly_parsed(self, conf_method_name, expected_value): config = ClusterRunnerConfig(self._COMPLETE_VALID_CONFIG) job_config = config.get_job_config() actual_value = getattr(job_config, conf_method_name) if isinstance(actual_value, Atomizer): actual_value = actual_value._atomizer_dicts # special case comparison for atomizer self.assertEqual(actual_value, expected_value, 'The output of {}() should match the expected value.'.format(conf_method_name))
def test_valid_conf_properties_are_correctly_parsed(self, config_string, expected_loaded_config): config = ClusterRunnerConfig(config_string) job_config = config.get_job_config() for method_name, expected_value in expected_loaded_config.items(): actual_value = getattr(job_config, method_name) if isinstance(actual_value, Atomizer): actual_value = actual_value._atomizer_dicts # special case comparison for atomizer self.assertEqual(actual_value, expected_value, 'The output of {}() should match the expected value.'.format(method_name))
def test_undefined_conf_properties_return_default_values( self, conf_method_name, expected_value): config = ClusterRunnerConfig(self._MINIMAL_CONFIG) job_config = config.get_job_config() actual_value = getattr(job_config, conf_method_name) self.assertEqual( actual_value, expected_value, 'The default output of {}() should match the expected value.'. format(conf_method_name))
def test_valid_configs_are_detected(self, config_contents, is_expected_valid): config = ClusterRunnerConfig(config_contents) try: config.get_job_config() except (ConfigParseError, ConfigValidationError) as e: self.assertFalse(is_expected_valid, 'Config is valid, but threw {}'.format(type(e))) return self.assertTrue(is_expected_valid, 'Config is not valid, but parsed without error')
def test_all_conf_properties_are_correctly_parsed(self, conf_method_name, expected_value): config = ClusterRunnerConfig(self._COMPLETE_VALID_CONFIG) job_config = config.get_job_config() actual_value = getattr(job_config, conf_method_name) if isinstance(actual_value, Atomizer): actual_value = actual_value._atomizer_dicts # special case comparison for atomizer self.assertEqual( actual_value, expected_value, 'The output of {}() should match the expected value.'.format( conf_method_name))
def test_valid_conf_properties_are_correctly_parsed( self, config_string, expected_loaded_config): config = ClusterRunnerConfig(config_string) job_config = config.get_job_config() for method_name, expected_value in expected_loaded_config.items(): actual_value = getattr(job_config, method_name) if isinstance(actual_value, Atomizer): actual_value = actual_value._atomizer_dicts # special case comparison for atomizer self.assertEqual( actual_value, expected_value, 'The output of {}() should match the expected value.'.format( method_name))
def job_config(self): """ Return the job config found in this project_type and matching any job_name parameter passed in :rtype: JobConfig """ if not self._job_config: # If the config was specified in the POST request, then there is no need to parse clusterrunner.yaml if self._config is not None: self._job_config = JobConfig.construct_from_dict(self._job_name, self._config) return self._job_config # Get job configuration from clusterrunner.yaml in repo. config = ClusterRunnerConfig(self._get_clusterrunner_config_file_contents()) self._job_config = config.get_job_config(self._job_name) return self._job_config
def test_config_with_background_task(self): config = ClusterRunnerConfig(self._BACKGROUND_TASK_CONFIG) job_config = config.get_job_config() self.assertEqual(job_config.setup_build, 'echo "in the background" & echo "in the foreground" && echo "another thing"')
def test_get_specific_job_config(self): config = ClusterRunnerConfig(self._MULTI_JOB_CONFIG) job_config = config.get_job_config('Second Job') self.assertEqual('Second Job', job_config.name, '') job_config = config.get_job_config('First Job') self.assertEqual('First Job', job_config.name, '')
def test_incorrect_atomizer_type_raises_exception(self, config_contents): config = ClusterRunnerConfig(config_contents) with self.assertRaises(ConfigValidationError): config.get_job_config()
def test_get_specific_job_config(self): config = ClusterRunnerConfig(self._MULTI_JOB_CONFIG) job_config = config.get_job_config('Second Job') self.assertEqual('Second Job', job_config.name, '') job_config = config.get_job_config('First Job') self.assertEqual('First Job', job_config.name, '')
def test_incorrect_atomizer_type_raises_exception(self, config_contents): config = ClusterRunnerConfig(config_contents) with self.assertRaises(ConfigValidationError): config.get_job_config()