Python oslotest.base.BaseTestCase() Examples

The following are 26 code examples of oslotest.base.BaseTestCase(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module oslotest.base , or try the search function .
Example #1
Source File: test_fixtures.py    From oslo.db with Apache License 2.0 6 votes vote down vote up
def test_skip_no_such_backend(self):

        class FakeDatabaseOpportunisticFixture(
                test_fixtures.OpportunisticDbFixture):
            DRIVER = 'postgresql+nosuchdbapi'

        class SomeTest(test_fixtures.OpportunisticDBTestMixin,
                       oslo_test_base.BaseTestCase):

            FIXTURE = FakeDatabaseOpportunisticFixture

            def runTest(self):
                pass

        st = SomeTest()

        ex = self.assertRaises(
            self.skipException,
            st.setUp
        )

        self.assertEqual(
            "Backend 'postgresql+nosuchdbapi' is unavailable: No such backend",
            str(ex)
        ) 
Example #2
Source File: utils.py    From barbican with Apache License 2.0 5 votes vote down vote up
def setUp(self):
        super(BaseTestCase, self).setUp()
        self.order_id = 'order1234'
        self.external_project_id = 'keystone1234'
        self.request_id = 'request1234' 
Example #3
Source File: test_base.py    From os-win with Apache License 2.0 5 votes vote down vote up
def setUp(self):
        super(BaseTestCase, self).setUp()
        self.useFixture(mock_fixture.MockAutospecFixture())
        self._patch_autospec_classes()
        self.addCleanup(mock.patch.stopall) 
Example #4
Source File: base.py    From monasca-log-api with Apache License 2.0 5 votes vote down vote up
def setUp(self):
        super(BaseTestCase, self).setUp()
        self.useFixture(ConfigFixture())
        self.useFixture(DisableStatsdFixture())
        self.useFixture(oo_ctx.ClearRequestContext())
        self.useFixture(PolicyFixture()) 
Example #5
Source File: base.py    From monasca-log-api with Apache License 2.0 5 votes vote down vote up
def _prepare_policy(self):
        policy_dir = self.useFixture(fixtures.TempDir())
        policy_file = os.path.join(policy_dir.path, 'policy.yaml')
        # load the fake_policy data and add the missing default rules.
        policy_rules = jsonutils.loads('{}')
        self.add_missing_default_rules(policy_rules)
        with open(policy_file, 'w') as f:
            jsonutils.dump(policy_rules, f)

        BaseTestCase.conf_override(policy_file=policy_file, group='oslo_policy')
        BaseTestCase.conf_override(policy_dirs=[], group='oslo_policy') 
Example #6
Source File: base.py    From monasca-notification with Apache License 2.0 5 votes vote down vote up
def setUp(self):
        super(BaseTestCase, self).setUp()
        self.useFixture(ConfigFixture())
        self.useFixture(DisableStatsdFixture()) 
Example #7
Source File: base.py    From monasca-api with Apache License 2.0 5 votes vote down vote up
def _prepare_policy(self):

        policy_dir = self.useFixture(fixtures.TempDir())
        policy_file = os.path.join(policy_dir.path, 'policy.yaml')

        policy_rules = jsonutils.loads('{}')

        self.add_missing_default_rules(policy_rules)

        with open(policy_file, 'w') as f:
            jsonutils.dump(policy_rules, f)

        BaseTestCase.conf_override(policy_file=policy_file,
                                   group='oslo_policy')
        BaseTestCase.conf_override(policy_dirs=[], group='oslo_policy') 
Example #8
Source File: base.py    From monasca-api with Apache License 2.0 5 votes vote down vote up
def setUp(self):
        super(BaseTestCase, self).setUp()
        self.useFixture(ConfigFixture(CONF))
        self.useFixture(EmptyPolicyFixture()) 
Example #9
Source File: base.py    From monasca-api with Apache License 2.0 5 votes vote down vote up
def _prepare_policy(self):
        policy_dir = self.useFixture(fixtures.TempDir())
        policy_file = os.path.join(policy_dir.path, 'policy.yaml')
        # load the fake_policy data and add the missing default rules.
        policy_rules = jsonutils.loads('{}')
        self.add_missing_default_rules(policy_rules)
        with open(policy_file, 'w') as f:
            jsonutils.dump(policy_rules, f)

        BaseTestCase.conf_override(policy_file=policy_file,
                                   group='oslo_policy')
        BaseTestCase.conf_override(policy_dirs=[], group='oslo_policy') 
Example #10
Source File: base.py    From monasca-api with Apache License 2.0 5 votes vote down vote up
def setUp(self):
        super(BaseTestCase, self).setUp()
        self.useFixture(ConfigFixture())
        self.useFixture(oo_ctx.ClearRequestContext())
        self.useFixture(PolicyFixture()) 
Example #11
Source File: utils.py    From oslo.db with Apache License 2.0 5 votes vote down vote up
def setUp(self, conf=cfg.CONF):
        super(BaseTestCase, self).setUp()
        self.conf = conf
        self.addCleanup(self.conf.reset) 
Example #12
Source File: test_fixtures.py    From oslo.db with Apache License 2.0 5 votes vote down vote up
def test_skip_no_dbapi(self):

        class FakeDatabaseOpportunisticFixture(
                test_fixtures.OpportunisticDbFixture):
            DRIVER = 'postgresql'

        class SomeTest(test_fixtures.OpportunisticDBTestMixin,
                       oslo_test_base.BaseTestCase):
            FIXTURE = FakeDatabaseOpportunisticFixture

            def runTest(self):
                pass

        st = SomeTest()

        # patch in replacement lookup dictionaries to avoid
        # leaking from/to other tests
        with mock.patch(
                "oslo_db.sqlalchemy.provision."
                "Backend.backends_by_database_type", {
                    "postgresql":
                    provision.Backend("postgresql", "postgresql://")}):
            st._database_resources = {}
            st._db_not_available = {}
            st._schema_resources = {}

            with mock.patch(
                    "sqlalchemy.create_engine",
                    mock.Mock(side_effect=ImportError())):

                self.assertEqual([], st.resources)

                ex = self.assertRaises(
                    self.skipException,
                    st.setUp
                )

        self.assertEqual(
            "Backend 'postgresql' is unavailable: No DBAPI installed",
            str(ex)
        ) 
Example #13
Source File: utils.py    From barbican with Apache License 2.0 5 votes vote down vote up
def tearDown(self):
        super(BaseTestCase, self).tearDown()
        ss_conf = config.get_module_config('secretstore')
        ss_conf.clear_override("enable_multiple_secret_stores",
                               group='secretstore') 
Example #14
Source File: base.py    From zun with Apache License 2.0 5 votes vote down vote up
def setUp(self):
        super(BaseTestCase, self).setUp()
        self.addCleanup(CONF.reset) 
Example #15
Source File: base.py    From python-barbicanclient with Apache License 2.0 5 votes vote down vote up
def tearDown(self):
        super(BaseTestCase, self).tearDown()
        self.LOG.info('Finished: %s\n', self._testMethodName) 
Example #16
Source File: base.py    From python-barbicanclient with Apache License 2.0 5 votes vote down vote up
def setUpClass(cls):
        cls.LOG = logging.getLogger(cls._get_full_case_name())
        super(BaseTestCase, cls).setUpClass() 
Example #17
Source File: utils.py    From python-barbicanclient with Apache License 2.0 5 votes vote down vote up
def tearDown(self):
        super(BaseTestCase, self).tearDown() 
Example #18
Source File: utils.py    From python-barbicanclient with Apache License 2.0 5 votes vote down vote up
def setUp(self):
        super(BaseTestCase, self).setUp()
        self.order_id = 'order1234'
        self.external_project_id = 'keystone1234' 
Example #19
Source File: base.py    From watcher with Apache License 2.0 5 votes vote down vote up
def setUp(self):
        super(BaseTestCase, self).setUp()
        self.addCleanup(cfg.CONF.reset) 
Example #20
Source File: utils.py    From sgx-kms with Apache License 2.0 5 votes vote down vote up
def tearDown(self):
        super(BaseTestCase, self).tearDown() 
Example #21
Source File: utils.py    From sgx-kms with Apache License 2.0 5 votes vote down vote up
def setUp(self):
        super(BaseTestCase, self).setUp()
        self.order_id = 'order1234'
        self.external_project_id = 'keystone1234'
        self.request_id = 'request1234' 
Example #22
Source File: test_log.py    From oslo.log with Apache License 2.0 5 votes vote down vote up
def setUp(self):
        super(BaseTestCase, self).setUp()
        self.context_fixture = self.useFixture(
            fixture_context.ClearRequestContext())
        self.config_fixture = self.useFixture(
            fixture_config.Config(cfg.ConfigOpts()))
        self.config = self.config_fixture.config
        self.CONF = self.config_fixture.conf
        log.register_options(self.CONF)
        log.setup(self.CONF, 'base') 
Example #23
Source File: test_cache.py    From oslo.cache with Apache License 2.0 5 votes vote down vote up
def setUp(self):
        super(BaseTestCase, self).setUp()
        self.config_fixture = self.useFixture(config_fixture.Config())
        self.config_fixture.config(
            # TODO(morganfainberg): Make Cache Testing a separate test case
            # in tempest, and move it out of the base unit tests.
            group='cache',
            backend='dogpile.cache.memory',
            enabled=True,
            proxies=['oslo_cache.testing.CacheIsolatingProxy']) 
Example #24
Source File: base.py    From magnum with Apache License 2.0 5 votes vote down vote up
def setUp(self):
        super(BaseTestCase, self).setUp()
        self.addCleanup(cfg.CONF.reset) 
Example #25
Source File: test.py    From compute-hyperv with Apache License 2.0 5 votes vote down vote up
def setUp(self):
        """Run before each test method to initialize test environment."""
        # Ensure BaseTestCase's ConfigureLogging fixture is disabled since
        # we're using the one from Nova (StandardLogging).
        with fixtures.EnvironmentVariable('OS_LOG_CAPTURE', '0'):
            super(NoDBTestCase, self).setUp()

        self.useFixture(mock_fixture.MockAutospecFixture())

        self.useFixture(log_fixture.get_logging_handle_error_fixture())

        self.useFixture(nova_fixtures.StandardLogging())
        self.useFixture(conf_fixture.ConfFixture(CONF))

        # NOTE(blk-u): WarningsFixture must be after the Database fixture
        # because sqlalchemy-migrate messes with the warnings filters.
        self.useFixture(nova_fixtures.WarningsFixture())

        self.addCleanup(self._clear_attrs)
        self.policy = self.useFixture(policy_fixture.PolicyFixture())

        self.useFixture(nova_fixtures.PoisonFunctions())

        if self.MOCK_TOOZ:
            self.patch('compute_hyperv.nova.coordination.Coordinator.start')
            self.patch('compute_hyperv.nova.coordination.Coordinator.stop')
            self.patch('compute_hyperv.nova.coordination.Coordinator.get_lock') 
Example #26
Source File: base.py    From ec2-api with Apache License 2.0 5 votes vote down vote up
def setUp(self):
        super(BaseTestCase, self).setUp()
        self._conf = self.useFixture(config_fixture.Config())
        self.configure(fatal_exception_format_errors=True)
        lock_path = self.useFixture(fixtures.TempDir()).path
        self.fixture = self.useFixture(
            config_fixture.Config(lockutils.CONF))
        self.fixture.config(lock_path=lock_path,
                            group='oslo_concurrency')