def test_stop_logging(self, shutdown): """ Make sure that stop_logging() calls logging.shutdown(). """ logs.stop_logging() shutdown.assert_called_once_with()
def test_stop_logging(self, shutdown): """ Make sure that stop_logging() calls logging.shutdown(). """ logs.stop_logging() shutdown.assert_called_once_with()
def setUpClass(cls): if not os.path.exists('/tmp/pulp'): os.makedirs('/tmp/pulp') stop_logging() config_filename = os.path.join(TEST_DATA_DIR, 'test-override-pulp.conf') config.config.read(config_filename) start_logging() manager_factory.initialize() constants.DISTRIBUTION_STORAGE_PATH = TEMP_DISTRO_STORAGE_DIR
def setUpClass(cls): if not os.path.exists('/tmp/pulp'): os.makedirs('/tmp/pulp') stop_logging() config_filename = os.path.join(TEST_DATA_DIR, 'test-override-pulp.conf') config.config.read(config_filename) start_logging() manager_factory.initialize() constants.DISTRIBUTION_STORAGE_PATH = TEMP_DISTRO_STORAGE_DIR
def setUpClass(cls): if not os.path.exists('/tmp/pulp'): os.makedirs('/tmp/pulp') stop_logging() config_filename = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'data', 'test-override-pulp.conf') config.config.read(config_filename) start_logging() name = config.config.get('database', 'name') connection.initialize(name) manager_factory.initialize()
def setUpClass(cls): if not os.path.exists('/tmp/pulp'): os.makedirs('/tmp/pulp') stop_logging() config_filename = os.path.join(os.path.abspath(os.path.dirname(__file__)), '../../../pulp_rpm/test/unit/data', 'test-override-pulp.conf') config.config.read(config_filename) start_logging() name = config.config.get('database', 'name') connection.initialize(name) manager_factory.initialize() constants.DISTRIBUTION_STORAGE_PATH = TEMP_DISTRO_STORAGE_DIR
def load_test_config(): if not os.path.exists('/tmp/pulp'): os.makedirs('/tmp/pulp') override_file = os.path.join(DATA_DIR, 'test-override-pulp.conf') stop_logging() try: config.add_config_file(override_file) except RuntimeError: pass start_logging() return config.config
def test_stop_logging(self, shutdown, get_logger): """ Make sure that stop_logging() calls logging.shutdown() and the handlers are cleared. """ get_logger.return_value.handlers = [1, 2, 3] # test logs.stop_logging() # validation shutdown.assert_called_once_with() self.assertEqual(get_logger.return_value.handlers, [])
def test_stop_logging(self, shutdown, get_logger): """ Make sure that stop_logging() calls logging.shutdown() and the handlers are cleared. """ get_logger.return_value.handlers = [1, 2, 3] # test logs.stop_logging() # validation shutdown.assert_called_once_with() self.assertEqual(get_logger.return_value.handlers, [])
def load_test_config(): if not os.path.exists('/tmp/pulp'): os.makedirs('/tmp/pulp') override_file = os.path.join(DATA_DIR, 'test-override-pulp.conf') stop_logging() try: config.add_config_file(override_file) except RuntimeError: pass start_logging() return config.config
def load_test_config(): if not os.path.exists('/tmp/pulp'): os.makedirs('/tmp/pulp') override_file = os.path.join(os.path.abspath(os.path.dirname(__file__)), '../data', 'test-override-pulp.conf') override_repo_file = os.path.join(os.path.abspath(os.path.dirname(__file__)), '../data', 'test-override-repoauth.conf') stop_logging() try: config.add_config_file(override_file) config.add_config_file(override_repo_file) except RuntimeError: pass start_logging() return config.config
def load_test_config(): if not os.path.exists('/tmp/pulp'): os.makedirs('/tmp/pulp') override_file = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'data', 'test-override-pulp.conf') override_repo_file = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'data', 'test-override-repoauth.conf') stop_logging() try: config.add_config_file(override_file) config.add_config_file(override_repo_file) except RuntimeError: pass start_logging() return config.config
def setUpClass(cls): if not os.path.exists(cls.TMP_ROOT): os.makedirs(cls.TMP_ROOT) stop_logging() path = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'data', 'pulp.conf') pulp_conf.read(path) start_logging() storage_dir = pulp_conf.get('server', 'storage_dir') if not os.path.exists(storage_dir): os.makedirs(storage_dir) shutil.rmtree(storage_dir + '/*', ignore_errors=True) name = pulp_conf.get('database', 'name') connection.initialize(name) managers.initialize()
def _load_test_config(): """ Load the test database configuration information. """ stop_logging() config.config.set('database', 'name', 'pulp_unittest') config.config.set('server', 'storage_dir', '/tmp/pulp') # Prevent the tests from altering the config so that nobody accidentally makes global changes config.config.set = _enforce_config config.load_configuration = _enforce_config config.__setattr__ = _enforce_config config.config.__setattr__ = _enforce_config start_logging()
def _load_test_config(): """ Load the test database configuration information. """ stop_logging() config.config.set('database', 'name', 'pulp_unittest') config.config.set('server', 'storage_dir', '/tmp/pulp') # Prevent the tests from altering the config so that nobody accidentally makes global changes config.config.set = _enforce_config config.load_configuration = _enforce_config config.__setattr__ = _enforce_config config.config.__setattr__ = _enforce_config start_logging()
def setUpClass(cls): # This will make Celery tasks run synchronously celery_instance.celery.conf.CELERY_ALWAYS_EAGER = True if not os.path.exists(cls.TMP_ROOT): os.makedirs(cls.TMP_ROOT) stop_logging() path = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'data', 'pulp.conf') pulp_conf.read(path) start_logging() storage_dir = pulp_conf.get('server', 'storage_dir') if not os.path.exists(storage_dir): os.makedirs(storage_dir) shutil.rmtree(storage_dir + '/*', ignore_errors=True) managers.initialize()
def setUpClass(cls): if not os.path.exists(cls.TMP_ROOT): os.makedirs(cls.TMP_ROOT) stop_logging() path = os.path.join( os.path.abspath(os.path.dirname(__file__)), 'data', 'pulp.conf') pulp_conf.read(path) start_logging() storage_dir = pulp_conf.get('server', 'storage_dir') if not os.path.exists(storage_dir): os.makedirs(storage_dir) shutil.rmtree(storage_dir+'/*', ignore_errors=True) name = pulp_conf.get('database', 'name') connection.initialize(name) managers.initialize()
def setUpClass(cls): # This will make Celery tasks run synchronously celery_instance.celery.conf.CELERY_ALWAYS_EAGER = True if not os.path.exists(cls.TMP_ROOT): os.makedirs(cls.TMP_ROOT) stop_logging() path = os.path.join( os.path.abspath(os.path.dirname(__file__)), 'data', 'pulp.conf') pulp_conf.read(path) start_logging() storage_dir = pulp_conf.get('server', 'storage_dir') if not os.path.exists(storage_dir): os.makedirs(storage_dir) shutil.rmtree(storage_dir+'/*', ignore_errors=True) managers.initialize()
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 setUpClass(cls): # This will make Celery tasks run synchronously celery_instance.celery.conf.CELERY_ALWAYS_EAGER = True cls.reserve_resources_patch = mock.patch( 'pulp.server.async.tasks._reserve_resource.' 'apply_async') mock_patch = cls.reserve_resources_patch.start() mock_patch.return_value.get.return_value = 'some_queue' if not os.path.exists(cls.TMP_ROOT): os.makedirs(cls.TMP_ROOT) stop_logging() path = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'data', 'pulp.conf') pulp_conf.read(path) start_logging() storage_dir = pulp_conf.get('server', 'storage_dir') if not os.path.exists(storage_dir): os.makedirs(storage_dir) shutil.rmtree(storage_dir + '/*', ignore_errors=True) name = pulp_conf.get('database', 'name') connection.initialize(name) managers.initialize()
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 setUpClass(cls): # This will make Celery tasks run synchronously celery_instance.celery.conf.CELERY_ALWAYS_EAGER = True cls.reserve_resources_patch = mock.patch('pulp.server.async.tasks._reserve_resource.' 'apply_async') mock_patch = cls.reserve_resources_patch.start() mock_patch.return_value.get.return_value = 'some_queue' if not os.path.exists(cls.TMP_ROOT): os.makedirs(cls.TMP_ROOT) stop_logging() path = os.path.join( os.path.abspath(os.path.dirname(__file__)), 'data', 'pulp.conf') pulp_conf.read(path) start_logging() storage_dir = pulp_conf.get('server', 'storage_dir') if not os.path.exists(storage_dir): os.makedirs(storage_dir) shutil.rmtree(storage_dir+'/*', ignore_errors=True) name = pulp_conf.get('database', 'name') connection.initialize(name) managers.initialize()
def tearDownClass(cls): stop_logging() shutil.rmtree('/tmp/pulp')
def tearDownClass(cls): stop_logging() name = config.config.get('database', 'name') connection._CONNECTION.drop_database(name) shutil.rmtree('/tmp/pulp')
def tearDownClass(cls): stop_logging() name = config.config.get('database', 'name') connection._CONNECTION.drop_database(name) shutil.rmtree('/tmp/pulp')
def tearDownClass(cls): stop_logging() shutil.rmtree('/tmp/pulp')