def test_file_load_counts(self): self.assertEqual(open.load_counts[self.config_1_name], 0) self.assertEqual(open.load_counts[self.config_2_name], 0) self.assertFalse(config.config._loaded) config.config.sections() # open was called, config is loaded self.assertEqual(open.load_counts[self.config_1_name], 1) self.assertEqual(open.load_counts[self.config_2_name], 1) self.assertTrue(config.config._loaded) config.config.sections() # open wasn't called again, config already loaded self.assertEqual(open.load_counts[self.config_1_name], 1) self.assertEqual(open.load_counts[self.config_2_name], 1) self.assertTrue(config.config._loaded) config.load_configuration() config.config.sections() # open was called again, config was reloaded self.assertEqual(open.load_counts[self.config_1_name], 2) self.assertEqual(open.load_counts[self.config_2_name], 2) # Both config files were loaded self.assertEqual(len(open.load_counts), 2)
def _load_test_config(): """ Load test configuration, reconfigure logging, block config changes during testing """ # prevent reading of server.conf block_load_conf() # allow altering the conf during config load, since we have to load the defaults restore_config_attrs() # force reloading the config config.load_configuration() # configure the test database config.config.set('database', 'name', 'pulp_unittest') config.config.set('server', 'storage_dir', '/tmp/pulp') # reset logging conf stop_logging() start_logging() # block future attempts to alter the config in place override_config_attrs()
def tearDown(self): # Reload the configuration so that things are cleaned up properly config.load_configuration() super(TestDatabaseReplicaSet, self).tearDown()
sys.stdout.write(os.linesep) def check(self): """ Loops through all models configured in MONGOENGINE_MODELS and tests them for validity """ for item in MONGOENGINE_MODELS: sys.stdout.write(item.__module__ + "." + item.__name__ + ": ") self.check_model(item) def _load_plugin_models(self): for entry_point in pkg_resources.iter_entry_points(MODEL_ENTRY_POINT): MONGOENGINE_MODELS.append(entry_point.load()) if __name__ == '__main__': call(["pulp-manage-db"]) config.load_configuration() db_connection.initialize() error_file = sys.stdout exception_handler = ValidationExceptionHandler(error_file) validation = ValidationCheck(exception_handler) validation.check()
sys.stdout.write(os.linesep) def check(self): """ Loops through all models configured in MONGOENGINE_MODELS and tests them for validity """ for item in MONGOENGINE_MODELS: sys.stdout.write(item.__name__ + ": ") self.check_model(item) if __name__ == '__main__': call(["pulp-manage-db"]) config.load_configuration() db_connection.initialize() datetime = time.strftime("%Y%m%d%H%M%S") error_file = open(ERROR_FILE_NAME.format(datetime), "w") exception_handler = ValidationExceptionHandler(error_file) validation = ValidationCheck(exception_handler) validation.check() if (validation.has_exceptions): sys.stdout.write( VALIDATION_ERROR_MESSAGE.format(ERROR_FILE_NAME.format(datetime)))