示例#1
0
    def test_stop_logging(self, shutdown):
        """
        Make sure that stop_logging() calls logging.shutdown().
        """
        logs.stop_logging()

        shutdown.assert_called_once_with()
示例#2
0
    def test_stop_logging(self, shutdown):
        """
        Make sure that stop_logging() calls logging.shutdown().
        """
        logs.stop_logging()

        shutdown.assert_called_once_with()
示例#3
0
 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
示例#4
0
 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
示例#5
0
 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()
示例#6
0
 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
示例#7
0
文件: base.py 项目: ipanova/pulp
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
示例#8
0
    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, [])
示例#9
0
    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, [])
示例#10
0
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
示例#11
0
文件: base.py 项目: tomlanyon/pulp
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
示例#12
0
文件: base.py 项目: ehelms/pulp
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
示例#13
0
 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()
示例#14
0
文件: base.py 项目: zjhuntin/pulp
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()
示例#15
0
文件: base.py 项目: jeremycline/pulp
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()
示例#16
0
文件: base.py 项目: taftsanders/pulp
    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()
示例#17
0
文件: base.py 项目: domcleal/pulp
 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()
示例#18
0
文件: base.py 项目: credativ/pulp
    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()
示例#19
0
文件: base.py 项目: taftsanders/pulp
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()
示例#20
0
    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()
示例#21
0
文件: base.py 项目: maxamillion/pulp
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()
示例#22
0
文件: base.py 项目: signull/pulp
    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()
示例#23
0
 def tearDownClass(cls):
     stop_logging()
     shutil.rmtree('/tmp/pulp')
示例#24
0
 def tearDownClass(cls):
     stop_logging()
     name = config.config.get('database', 'name')
     connection._CONNECTION.drop_database(name)
     shutil.rmtree('/tmp/pulp')
示例#25
0
 def tearDownClass(cls):
     stop_logging()
     name = config.config.get('database', 'name')
     connection._CONNECTION.drop_database(name)
     shutil.rmtree('/tmp/pulp')
示例#26
0
 def tearDownClass(cls):
     stop_logging()
     shutil.rmtree('/tmp/pulp')