当前位置: 首页>>代码示例>>Python>>正文


Python StackInABox.register_service方法代码示例

本文整理汇总了Python中stackinabox.stack.StackInABox.register_service方法的典型用法代码示例。如果您正苦于以下问题:Python StackInABox.register_service方法的具体用法?Python StackInABox.register_service怎么用?Python StackInABox.register_service使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在stackinabox.stack.StackInABox的用法示例。


在下文中一共展示了StackInABox.register_service方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

# 需要导入模块: from stackinabox.stack import StackInABox [as 别名]
# 或者: from stackinabox.stack.StackInABox import register_service [as 别名]
 def setUp(self):
     super(TestKeystoneV2UserGet, self).setUp()
     self.keystone = KeystoneV2Service()
     self.headers = {
         'x-auth-token': self.keystone.model.tokens.admin_token
     }
     StackInABox.register_service(self.keystone)
开发者ID:BenjamenMeyer,项目名称:openstackinabox,代码行数:9,代码来源:test_get.py

示例2: wrapped

# 需要导入模块: from stackinabox.stack import StackInABox [as 别名]
# 或者: from stackinabox.stack.StackInABox import register_service [as 别名]
        def wrapped(*args, **kwargs):
            args_copy = list(args)
            for arg in self.args:
                args_copy.append(arg)
            args_finalized = tuple(args_copy)
            kwargs.update(self.kwargs)

            if self.enable_service_access is not None:
                kwargs[self.enable_service_access] = self.services

            with requests_mock_activate():
                if self.session is not None:
                    kwargs[self.session] = requests.Session()

                    StackInABox.reset_services()
                    for service in self.services.values():
                        StackInABox.register_service(service)
                    requests_mock_session_registration(
                        self.uri,
                        kwargs[self.session]
                    )
                    return_value = fn(*args_finalized, **kwargs)
                    StackInABox.reset_services()

                else:
                    StackInABox.reset_services()
                    for service in self.services.values():
                        StackInABox.register_service(service)
                    requests_mock_registration(self.uri)
                    return_value = fn(*args_finalized, **kwargs)
                    StackInABox.reset_services()

            return return_value
开发者ID:BenjamenMeyer,项目名称:stackInABox,代码行数:35,代码来源:decorator.py

示例3: test_double_service_registration

# 需要导入模块: from stackinabox.stack import StackInABox [as 别名]
# 或者: from stackinabox.stack.StackInABox import register_service [as 别名]
    def test_double_service_registration(self):
        service1 = HelloService()
        service2 = HelloService()

        StackInABox.register_service(service1)
        with self.assertRaises(ServiceAlreadyRegisteredError):
            StackInABox.register_service(service2)
开发者ID:kidster,项目名称:stackInABox,代码行数:9,代码来源:test_stack.py

示例4: setUp

# 需要导入模块: from stackinabox.stack import StackInABox [as 别名]
# 或者: from stackinabox.stack.StackInABox import register_service [as 别名]
 def setUp(self):
     super(TestKeystoneV2UserAddCredentials, self).setUp()
     self.keystone = KeystoneV2Service()
     self.headers = {
         'x-auth-token': self.keystone.model.tokens.admin_token
     }
     self.tenant_id = self.keystone.model.tenants.add(
         tenant_name='neo',
         description='The One'
     )
     self.user_info = {
         'user': {
             'username': 'trinity',
             'enabled': True,
             'email': '[email protected]',
             'password': 'Inl0veWithNeo'
         }
     }
     self.user_info['user']['userid'] = self.keystone.model.users.add(
         tenant_id=self.tenant_id,
         username=self.user_info['user']['username'],
         email=self.user_info['user']['email'],
         password=self.user_info['user']['password'],
         enabled=self.user_info['user']['enabled']
     )
     self.keystone.model.tokens.add(
         tenant_id=self.tenant_id,
         user_id=self.user_info['user']['userid']
     )
     self.keystone.model.roles.add_user_role_by_role_name(
         tenant_id=self.tenant_id,
         user_id=self.user_info['user']['userid'],
         role_name=self.keystone.model.roles.IDENTITY_ADMIN_ROLE
     )
     StackInABox.register_service(self.keystone)
开发者ID:BenjamenMeyer,项目名称:openstackinabox,代码行数:37,代码来源:test_add_credentials.py

示例5: setUp

# 需要导入模块: from stackinabox.stack import StackInABox [as 别名]
# 或者: from stackinabox.stack.StackInABox import register_service [as 别名]
 def setUp(self):
     super(TestKeystoneV2UserUpdate, self).setUp()
     self.keystone = KeystoneV2Service()
     self.headers = {
         'x-auth-token': self.keystone.model.tokens.admin_token
     }
     self.tenant_id = self.keystone.model.tenants.add(
         tenant_name='neo',
         description='The One'
     )
     self.user_info = {
         'user': {
             'username': 'trinity',
             'enabled': True,
             'email': '[email protected]',
             'OS-KSADM:password': 'Inl0veWithNeo'
         }
     }
     self.user_info['user']['userid'] = self.keystone.model.users.add(
         tenant_id=self.tenant_id,
         username=self.user_info['user']['username'],
         email=self.user_info['user']['email'],
         password=self.user_info['user']['OS-KSADM:password'],
         enabled=self.user_info['user']['enabled']
     )
     self.keystone.model.tokens.add(
         tenant_id=self.tenant_id,
         user_id=self.user_info['user']['userid']
     )
     StackInABox.register_service(self.keystone)
开发者ID:BenjamenMeyer,项目名称:openstackinabox,代码行数:32,代码来源:test_update.py

示例6: setUp

# 需要导入模块: from stackinabox.stack import StackInABox [as 别名]
# 或者: from stackinabox.stack.StackInABox import register_service [as 别名]
 def setUp(self):
     super(TestKeystoneV2UserListing, self).setUp()
     self.keystone = KeystoneV2Service()
     self.headers = {
         'x-auth-token': self.keystone.model.get_admin_token()
     }
     StackInABox.register_service(self.keystone)
开发者ID:ananthanithya,项目名称:openstackinabox,代码行数:9,代码来源:test_keystone_v2_user_listing.py

示例7: test_service_exception

# 需要导入模块: from stackinabox.stack import StackInABox [as 别名]
# 或者: from stackinabox.stack.StackInABox import register_service [as 别名]
    def test_service_exception(self):
        exceptional = ExceptionalServices()
        StackInABox.register_service(exceptional)

        stackinabox.util_httpretty.httpretty_registration('localhost')

        res = requests.get('http://localhost/except/')
        self.assertEqual(res.status_code, 596)
开发者ID:kidster,项目名称:stackInABox,代码行数:10,代码来源:test_stack.py

示例8: setUp

# 需要导入模块: from stackinabox.stack import StackInABox [as 别名]
# 或者: from stackinabox.stack.StackInABox import register_service [as 别名]
 def setUp(self):
     super(TestHttprettyKeystone, self).setUp()
     self.keystone = KeystoneV2Service()
     self.headers = {
         'x-auth-token': self.keystone.model.tokens.admin_token
     }
     StackInABox.register_service(self.keystone)
     self.session = requests.Session()
开发者ID:BenjamenMeyer,项目名称:openstackinabox,代码行数:10,代码来源:test_keystone.py

示例9: run

# 需要导入模块: from stackinabox.stack import StackInABox [as 别名]
# 或者: from stackinabox.stack.StackInABox import register_service [as 别名]
    def run():
        StackInABox.reset_services()
        StackInABox.register_service(HelloService())
        stackinabox.util.responses.registration('localhost')

        res = requests.get('http://localhost/hello/')
        assert res.status_code == 200
        assert res.text == 'Hello'
开发者ID:BenjamenMeyer,项目名称:stackInABox,代码行数:10,代码来源:test_core.py

示例10: run

# 需要导入模块: from stackinabox.stack import StackInABox [as 别名]
# 或者: from stackinabox.stack.StackInABox import register_service [as 别名]
            def run():
                responses.mock.start()

                StackInABox.reset_services()
                for service in self.services.values():
                    StackInABox.register_service(service)
                responses_registration(self.uri)
                return_value = fn(*args_finalized, **kwargs)
                StackInABox.reset_services()

                responses.mock.stop()
                responses.mock.reset()
开发者ID:BenjamenMeyer,项目名称:stackInABox,代码行数:14,代码来源:decorator.py

示例11: setUp

# 需要导入模块: from stackinabox.stack import StackInABox [as 别名]
# 或者: from stackinabox.stack.StackInABox import register_service [as 别名]
 def setUp(self):
     super(TestKeystoneV2UserAdd, self).setUp()
     self.keystone = KeystoneV2Service()
     self.headers = {
         'x-auth-token': self.keystone.model.get_admin_token()
     }
     self.user_info = {
         'user': {
             'username': 'trinity',
             'enabled': True,
             'email': '[email protected]',
             'OS-KSADM:password': 'Inl0veWithNeo'
         }
     }
     StackInABox.register_service(self.keystone)
开发者ID:ananthanithya,项目名称:openstackinabox,代码行数:17,代码来源:test_keystone_v2_user_add.py

示例12: test_subservice_registration

# 需要导入模块: from stackinabox.stack import StackInABox [as 别名]
# 或者: from stackinabox.stack.StackInABox import register_service [as 别名]
    def test_subservice_registration(self):
        service = AnotherAdvancedService()
        subservice = YetAnotherService()
        service.register_subservice(re.compile('^/french'),
                                    subservice)

        StackInABox.register_service(service)

        stackinabox.util_httpretty.httpretty_registration('localhost')

        res = requests.get('http://localhost/aas/french')
        self.assertEqual(res.status_code,
                         200)
        self.assertEqual(res.text,
                         'bonjour')
开发者ID:kidster,项目名称:stackInABox,代码行数:17,代码来源:test_service.py

示例13: setUp

# 需要导入模块: from stackinabox.stack import StackInABox [as 别名]
# 或者: from stackinabox.stack.StackInABox import register_service [as 别名]
    def setUp(self):
        super(TestKeystoneV2AuthBase, self).setUp()

        self.tenantname = self.make_tenant_name()
        self.keystone = KeystoneV2Service()
        self.username = 'user_{0}'.format(str(uuid.uuid4()))
        self.password = 'pAss{0}'.format(
            str(uuid.uuid4()).replace('-', '')
        )
        self.apikey = str(uuid.uuid4())
        self.email = '{0}@stackinabox.mock'.format(self.username)
        self.keystone.model.tenants.add(
            tenant_name=self.tenantname,
            description="test tenant"
        )
        tenant_data = self.keystone.model.tenants.get_by_name(
            tenant_name=self.tenantname
        )
        self.tenantid = tenant_data['id']

        self.keystone.model.users.add(
            tenant_id=self.tenantid,
            username=self.username,
            password=self.password,
            apikey=self.apikey,
            email=self.email
        )
        user_data = self.keystone.model.users.get_by_name(
            tenant_id=self.tenantid,
            username=self.username
        )
        self.userid = user_data['user_id']
        self.token = self.keystone.model.tokens.make_token()
        self.keystone.model.tokens.add(
            tenant_id=self.tenantid,
            user_id=self.userid,
            token=self.token
        )

        StackInABox.register_service(self.keystone)
开发者ID:BenjamenMeyer,项目名称:openstackinabox,代码行数:42,代码来源:base.py

示例14: setUp

# 需要导入模块: from stackinabox.stack import StackInABox [as 别名]
# 或者: from stackinabox.stack.StackInABox import register_service [as 别名]
 def setUp(self):
     super(TestRequestMockAdvanced, self).setUp()
     StackInABox.register_service(AdvancedService())
     self.session = requests.Session()
开发者ID:kidster,项目名称:stackInABox,代码行数:6,代码来源:test_requests_mock.py

示例15: setUp

# 需要导入模块: from stackinabox.stack import StackInABox [as 别名]
# 或者: from stackinabox.stack.StackInABox import register_service [as 别名]
 def setUp(self):
     super(TestHttprettyBasic, self).setUp()
     StackInABox.register_service(HelloService())
开发者ID:BenjamenMeyer,项目名称:stackInABox,代码行数:5,代码来源:test_core.py


注:本文中的stackinabox.stack.StackInABox.register_service方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。