本文整理汇总了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)
示例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
示例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)
示例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)
示例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)
示例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)
示例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)
示例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()
示例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'
示例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()
示例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)
示例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')
示例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)
示例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()
示例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())