def test_config_manager_run_script_environment_is_not_lost_if_modified_directly( self): config_manager = ConfigManager() config_manager.config()['run_script_environment'].update( self.run_script_environment) self.assertEqual(self.run_script_environment, config_manager.config()['run_script_environment'])
def test_config_returns_copy_after_freeze(self): config_manager = ConfigManager() config_manager['hello'] = 'goodbye' config_manager.freeze() config_manager.config()['second'] = 'changed thing' self.assertEqual({ 'hello': 'goodbye', 'run_script_environment': {} }, config_manager.config())
def test_reset_clears_config_paths(self): from foundations_internal.change_directory import ChangeDirectory config_manager = ConfigManager() with ChangeDirectory('test/fixtures/single_config'): config_manager.config() config_manager.reset() self.assertEqual([], config_manager.config_paths())
def test_reset_allows_for_reloading_from_environment_variables_when_config_called( self): config_manager = ConfigManager() config_manager['FOUNDATIONS_TEST'] = "test_string" self.assertEqual('test_string', config_manager['FOUNDATIONS_TEST']) config_manager.reset() self.assertIsNone(config_manager.config().get('FOUNDATIONS_TEST'))
def test_add_config_path_after_configured(self): config_manager = ConfigManager() config_manager.add_config_path( 'test/fixtures/multiple_configs/first.config.yaml') config = config_manager.config() config_manager.add_config_path( 'test/fixtures/multiple_configs/second.config.yaml') self._assert_is_subset( { 'title': 'test config', 'value': 'different value' }, config)
class TestDeploymentManager(unittest.TestCase): class MockDeployment(object): def __init__(self, job_name, job, job_source_bundle): self._job_name = job_name def config(self): return {} def deploy(self): pass def job_name(self): return self._job_name class MockListing(object): def __init__(self): self.project_tracked = False self.value = None def track_pipeline(self, name): self.project_tracked = True self.value = name def setUp(self): from foundations_contrib.config_manager import ConfigManager from foundations_internal.deployment_manager import DeploymentManager from foundations_internal.pipeline import Pipeline from foundations_internal.pipeline_context import PipelineContext from foundations_internal.foundations_context import FoundationsContext self._listing = self.MockListing() self._config = ConfigManager() self._config["deployment_implementation"] = { "deployment_type": self.MockDeployment } self._config["project_listing_implementation"] = { "project_listing_type": self._mock_listing, } self._deployment_manager = DeploymentManager(self._config) self._pipeline_context = PipelineContext() self._pipeline = Pipeline(self._pipeline_context) self._foundations_context = FoundationsContext(self._pipeline) def test_deploy_persisted_project_name(self): self._foundations_context.set_project_name("my project") self._deployment_manager.simple_deploy(self._pipeline, "", {}) self.assertEqual("my project", self._listing.value) def test_deploy_persisted_project_name_different_name(self): self._foundations_context.set_project_name("project potato launcher") self._deployment_manager.simple_deploy(self._pipeline, "", {}) self.assertEqual("project potato launcher", self._listing.value) @patch( "foundations_contrib.null_pipeline_archive_listing.NullPipelineArchiveListing" ) def test_deploy_persisted_project_name_supports_default_listing( self, mock_null_pipeline): mock_null_pipeline.side_effect = self._mock_listing del self._config.config()["project_listing_implementation"] self._foundations_context.set_project_name("my project") self._deployment_manager.simple_deploy(self._pipeline, "", {}) self.assertEqual("my project", self._listing.value) def _mock_listing(self): return self._listing def _method(self): pass
def test_config_manager_get_run_script_environment_defaults_to_empty_dict( self): config_manager = ConfigManager() self.assertEqual({}, config_manager.config()['run_script_environment'])
def test_indexer_multiple_value(self): config_manager = ConfigManager() config_manager.config()['hello'] = 'goodbye' config_manager.config()['next'] = 'thing' self.assertEqual('thing', config_manager['next'])
def test_indexer_different_key(self): config_manager = ConfigManager() config_manager.config()['next'] = 'thing' self.assertEqual('thing', config_manager['next'])
def test_indexer(self): config_manager = ConfigManager() config_manager.config()['hello'] = 'goodbye' self.assertEqual('goodbye', config_manager['hello'])
def test_persist_config_with_different_values(self): config_manager = ConfigManager() config_manager.config()['foo'] = 'bar' self._assert_is_subset({'foo': 'bar'}, config_manager.config())
def test_persist_config(self): config_manager = ConfigManager() config_manager.config()['hello'] = 'goodbye' self._assert_is_subset({'hello': 'goodbye'}, config_manager.config())
def test_should_be_empty_by_default(self): config_manager = ConfigManager() self.assertEqual({'run_script_environment': {}}, config_manager.config())