def test_load_test_config_after_override(self): """ _load_test_config works even when config modifications are disallowed beforehand """ # _load_test_config is able to modify the config even after override is called... base.override_config_attrs() # If something was wrong, this would raise Exception base._load_test_config() # but attempts to alter the config afterwatd are still blocked self.assertRaises(Exception, config.config.set, 'section', 'key', 'value')
def test_load_test_config(self, start_logging, stop_logging, override): """ Assert correct operation of the function. """ base._load_test_config() # Logging should have been started and stopped start_logging.assert_called_once_with() stop_logging.assert_called_once_with() # Ensure that the correct settings have been put into place self.assertEqual(config.config.get('database', 'name'), 'pulp_unittest') self.assertEqual(config.config.get('server', 'storage_dir'), '/tmp/pulp') # Ensure that the config tampering prevention was triggered override.assert_called_once_with()
def test_load_test_config(self, start_logging, stop_logging, config_set): """ Assert correct operation of the function. """ base._load_test_config() # Logging should have been started and stopped start_logging.assert_called_once_with() stop_logging.assert_called_once_with() # Ensure that the correct settings have been put into place self.assertEqual( [c[1] for c in config_set.mock_calls], [('database', 'name', 'pulp_unittest'), ('server', 'storage_dir', '/tmp/pulp')]) # Ensure that the config doesn't allow tampering self.assertTrue(config.config.set is base._enforce_config) self.assertTrue(config.load_configuration is base._enforce_config) self.assertTrue(config.__setattr__ is base._enforce_config) self.assertTrue(config.config.__setattr__ is base._enforce_config)