Esempio n. 1
0
 def setup_context(self, username="******", tenant_id="tenant_1",
                   token="test_auth_token", tenant_name='test_tenant',
                   **kwargs):
     self.addCleanup(context.set_ctx,
                     context.ctx() if context.has_ctx() else None)
     context.set_ctx(context.Context(
         username=username, tenant_id=tenant_id,
         token=token, service_catalog={},
         tenant_name=tenant_name, **kwargs))
Esempio n. 2
0
    def setup_context(self, username="******", tenant_id="tenant_1",
                      auth_token="test_auth_token", tenant_name='test_tenant',
                      service_catalog=None, **kwargs):
        self.addCleanup(context.set_ctx,
                        context.ctx() if context.has_ctx() else None)

        context.set_ctx(context.Context(
            username=username, tenant_id=tenant_id,
            auth_token=auth_token, service_catalog=service_catalog or {},
            tenant_name=tenant_name, **kwargs))
Esempio n. 3
0
    def test_context_cleared_in_case_of_exception(self):
        with mock_validate_config() as validate_config:
            validate_config.side_effect = SomeException
            self.assertRaises(SomeException, main.validate_castellan_config)

        self.assertFalse(context.has_ctx())
Esempio n. 4
0
    def test_context_cleared(self):
        with mock_validate_config():
            main.validate_castellan_config()

        self.assertFalse(context.has_ctx())
Esempio n. 5
0
 def check_context():
     self.assertTrue(context.has_ctx())
Esempio n. 6
0
    def test_context_cleared_in_case_of_exception(self):
        with mock_validate_config() as validate_config:
            validate_config.side_effect = SomeException
            self.assertRaises(SomeException, main.validate_castellan_config)

        self.assertFalse(context.has_ctx())
Esempio n. 7
0
    def test_context_cleared(self):
        with mock_validate_config():
            main.validate_castellan_config()

        self.assertFalse(context.has_ctx())
Esempio n. 8
0
 def check_context():
     self.assertTrue(context.has_ctx())
Esempio n. 9
0
def has_ctx(**kwargs):
    return context.has_ctx()