本文整理汇总了Python中tests.doubles.make函数的典型用法代码示例。如果您正苦于以下问题:Python make函数的具体用法?Python make怎么用?Python make使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了make函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_create_fw_rule_sets
def test_create_fw_rule_sets(self):
params = {
u'project': u'PID',
u'name': u'name',
u'image': u'image',
u'instance-type': u'flavor',
u'fw-rule-sets': [u'3', u'8']
}
sgs = [
doubles.make(self.mox, doubles.SecurityGroup, id=u'3', name='sg3'),
doubles.make(self.mox, doubles.SecurityGroup, id=u'8', name='sg8')
]
instances.client_set_for_tenant(u'PID').AndReturn(self.tcs)
self.tcs.compute.security_groups.get(u'3').AndReturn(sgs[0])
self.tcs.compute.security_groups.get(u'8').AndReturn(sgs[1])
self.tcs.compute.servers.create(
name=u'name',
image=u'image',
flavor=u'flavor',
security_groups=['sg3', 'sg8'],
key_name=None,
admin_pass=None
).AndReturn('VM1')
instances._instance_to_view('VM1').AndReturn('REPLY')
self.mox.ReplayAll()
data = self.interact(params)
self.assertEquals(data, 'REPLY')
开发者ID:altai,项目名称:altai-api,代码行数:28,代码来源:test_collection_vms.py
示例2: test_project_creation_works
def test_project_creation_works(self):
self.mox.StubOutWithMock(projects, '_project_to_view')
self.mox.StubOutWithMock(projects, '_quotaset_for_project')
networks = self.fake_client_set.compute.networks
tenants = self.fake_client_set.identity_admin.tenants
tenant = doubles.make(self.mox, doubles.Tenant,
name=self.name, id='PID',
description=self.description)
networks.get(self.net_id).AndReturn(
doubles.make(self.mox, doubles.Network,
label='NETLABEL', id=self.net_id, project_id=None))
tenants.create(self.name, self.description).AndReturn(tenant)
networks.associate(self.net_id, tenant.id)
networks.get(self.net_id).AndReturn('UPDATED NETWORK')
projects._quotaset_for_project(tenant.id).AndReturn('QUOTA')
projects._project_to_view(tenant, 'UPDATED NETWORK', 'QUOTA')\
.AndReturn('REPLY')
self.mox.ReplayAll()
data = self.interact()
self.assertEquals(data, 'REPLY')
开发者ID:altai,项目名称:altai-api,代码行数:25,代码来源:test_collection_projects.py
示例3: test_net_to_dict_works
def test_net_to_dict_works(self):
net = doubles.make(self.mox, doubles.Network,
id='271',
label='testnet',
vlan=42,
cidr='10.5.2.0/24',
netmask='255.255.255.0',
project_id='PID')
tenant = doubles.make(self.mox, doubles.Tenant,
id='PID', name='ptest')
expected = {
'id': '271',
'href': '/v1/networks/271',
'name': 'testnet',
'vlan': 42,
'cidr': '10.5.2.0/24',
'used': True,
'project': {
u'href': '/v1/projects/PID',
u'id': 'PID',
u'name': 'ptest'
}
}
self.fake_client_set.identity_admin\
.tenants.get(u'PID').AndReturn(tenant)
self.mox.ReplayAll()
with self.app.test_request_context():
self.install_fake_auth()
data = networks._net_to_dict(net)
self.assertEquals(data, expected)
开发者ID:altai,项目名称:altai-api,代码行数:32,代码来源:test_collection_networks.py
示例4: test_list_works
def test_list_works(self):
tenants = (
doubles.make(self.mox, doubles.Tenant, name='t1', id=u'PID1'),
doubles.make(self.mox, doubles.Tenant, name='systenant', id=u'S'),
doubles.make(self.mox, doubles.Tenant, name='t2', id=u'PID2'))
self.fake_client_set.identity_admin.tenants.list().AndReturn(tenants)
tcs1 = mock_client_set(self.mox)
fw_rule_sets.client_set_for_tenant(u'PID1', fallback_to_api=True) \
.AndReturn(tcs1)
tcs1.compute.security_groups.list().AndReturn(['SG1', 'SG2'])
fw_rule_sets._sg_to_view('SG1', tenants[0].name).AndReturn('REPLY1')
fw_rule_sets._sg_to_view('SG2', tenants[0].name).AndReturn('REPLY2')
tcs2 = mock_client_set(self.mox)
fw_rule_sets.client_set_for_tenant(u'PID2', fallback_to_api=True) \
.AndReturn(tcs2)
tcs2.compute.security_groups.list().AndReturn(['SG3'])
fw_rule_sets._sg_to_view('SG3', tenants[2].name).AndReturn('REPLY3')
expected = {
'collection': {
'name': 'fw-rule-sets',
'size': 3
},
'fw-rule-sets': ['REPLY1', 'REPLY2', 'REPLY3']
}
self.mox.ReplayAll()
rv = self.client.get('/v1/fw-rule-sets/')
data = self.check_and_parse_response(rv)
self.assertEquals(data, expected)
开发者ID:altai,项目名称:altai-api,代码行数:33,代码来源:test_collection_fw_rule_sets.py
示例5: test_remind_reminds
def test_remind_reminds(self):
server_mgr = self.fake_client_set.compute.servers
instances.admin_client_set().AndReturn(self.fake_client_set)
user_mgr = self.fake_client_set.identity_admin.users
server = doubles.make(self.mox, doubles.Server,
id='v2', name='instance-2', user_id='UID')
user = doubles.make(self.mox, doubles.User,
id='UID', name='user', email='[email protected]',
fullname='The Test User Fullname')
expires = datetime(2013, 1, 19, 11, 12, 13)
instances.datetime.utcnow().AndReturn('UTCNOW')
instances.InstanceDataDAO.remind_list('UTCNOW')\
.AndReturn([InstanceData(instance_id='v2',
expires_at=expires)])
server_mgr.get('v2').AndReturn(server)
user_mgr.get('UID').AndReturn(user)
instances.send_instance_reminder(user.email, 'instance-2', 'v2',
expires, greeting=user.fullname)
instances.InstanceDataDAO.update('v2', remind_at=None)
self.mox.ReplayAll()
with self.app.test_request_context():
instances.remind_about_instances()
开发者ID:altai,项目名称:altai-api,代码行数:25,代码来源:test_jobs_vms.py
示例6: test_image_to_view_works
def test_image_to_view_works(self):
tenant = doubles.make(self.mox, doubles.Tenant, id=u"TENANT", name=u"TestTenant")
image = doubles.make(
self.mox,
doubles.Image,
id=u"IMAGE",
name=u"TestImage",
size=123456,
owner=tenant.id,
created_at="2012-10-15T01:43:00",
disk_format=u"raw",
container_format=u"bare",
checksum="831a05f7bdeadbabe5l1k3133715e7ea",
status="active",
)
expected = {
u"id": u"IMAGE",
u"href": "/v1/images/IMAGE",
u"data-href": "/v1/images/IMAGE/data",
u"name": u"TestImage",
u"global": False,
u"project": {u"id": u"TENANT", u"name": u"TestTenant", u"href": "/v1/projects/TENANT"},
u"created": datetime(2012, 10, 15, 01, 43, 00),
u"disk-format": u"raw",
u"container-format": u"bare",
u"md5sum": "831a05f7bdeadbabe5l1k3133715e7ea",
u"size": 123456,
u"status": u"active",
}
开发者ID:altai,项目名称:altai-api,代码行数:29,代码来源:test_collection_images.py
示例7: test_project_to_view_no_quota
def test_project_to_view_no_quota(self):
tenant = doubles.make(self.mox, doubles.Tenant,
id=u'c4fc65e', name=u'Project X')
net = doubles.make(self.mox, doubles.Network,
label=u'net22', id=u'2699a5')
expected = {
u'id': u'c4fc65e',
u'href': u'/v1/projects/c4fc65e',
u'name': u'Project X',
u'description': u'Rather long description.',
u'links': {
u'manage-users': '/v1/projects/c4fc65e/users/',
u'stats': '/v1/stats/by-project/c4fc65e'
},
u'network': {
u'id': u'2699a5',
u'name': u'net22',
u'href': u'/v1/networks/2699a5'
}
}
with self.app.test_request_context():
result = projects._project_to_view(tenant, net, None)
self.assertEquals(expected, result)
开发者ID:altai,项目名称:altai-api,代码行数:25,代码来源:test_collection_projects.py
示例8: test_sg_to_view_works
def test_sg_to_view_works(self):
tenant = doubles.make(self.mox, doubles.Tenant,
id=u'PID', name=u'Tenant')
sg = doubles.make(self.mox, doubles.SecurityGroup,
id=42, name=u'Test SG',
description=u'XXX', tenant_id=u'PID')
expected = {
u'id': u'42',
u'name': u'Test SG',
u'description': u'XXX',
u'project': {
u'id': u'PID',
u'href': '/v1/projects/PID',
u'name': u'Tenant'
},
u'rules-href': u'/v1/fw-rule-sets/42/rules/',
u'href': u'/v1/fw-rule-sets/42'
}
self.mox.ReplayAll()
with self.app.test_request_context():
res = fw_rule_sets._sg_to_view(sg, tenant.name)
self.assertEquals(expected, res)
开发者ID:altai,项目名称:altai-api,代码行数:25,代码来源:test_collection_fw_rule_sets.py
示例9: test_get_all_projects
def test_get_all_projects(self):
tenants = (
doubles.make(self.mox, doubles.Tenant, name=u'tnt1', id=u't1'),
doubles.make(self.mox, doubles.Tenant, name=u'tnt2', id=u't2'),
doubles.make(self.mox, doubles.Tenant,
name=u'systenant', id=u'SYSTENANT_ID'))
nets = (
self.net(label=u'net2', id=u'netid2', project_id=u't2'),
self.net(label=u'net_', id=u'netid_', project_id=None), # unused
self.net(label=u'net1', id=u'netid1', project_id=u't1'))
self.tm_mock.list().AndReturn(tenants)
self.nm_mock.list().AndReturn(nets)
projects._quotaset_for_project(u't1').AndReturn('QUOTA1')
projects._project_to_view(tenants[0], nets[2], 'QUOTA1')\
.AndReturn('PROJECT1')
projects._quotaset_for_project(u't2').AndReturn('QUOTA2')
projects._project_to_view(tenants[1], nets[0], 'QUOTA2')\
.AndReturn('PROJECT2')
expected = {
u'collection': {
u'name': u'projects',
u'size': 2
},
u'projects': [ 'PROJECT1', 'PROJECT2' ]
}
self.mox.ReplayAll()
rv = self.client.get('/v1/projects/')
data = self.check_and_parse_response(rv)
self.assertEquals(data, expected)
开发者ID:altai,项目名称:altai-api,代码行数:34,代码来源:test_collection_projects.py
示例10: test_project_to_view_works
def test_project_to_view_works(self):
tenant = doubles.make(self.mox, doubles.Tenant,
id=u'c4fc65e', name=u'Project X')
net = doubles.make(self.mox, doubles.Network,
label=u'net22', id=u'2699a5')
quotaset = doubles.make(self.mox, doubles.QuotaSet)
gb = 1024 * 1024 * 1024
expected = {
u'id': u'c4fc65e',
u'href': u'/v1/projects/c4fc65e',
u'name': u'Project X',
u'description': u'Rather long description.',
u'cpus-limit': 33,
u'ram-limit': 50 * gb,
u'instances-limit': 10,
u'links': {
u'manage-users': '/v1/projects/c4fc65e/users/',
u'stats': '/v1/stats/by-project/c4fc65e'
},
u'network': {
u'id': u'2699a5',
u'name': u'net22',
u'href': u'/v1/networks/2699a5'
}
}
with self.app.test_request_context():
result = projects._project_to_view(tenant, net, quotaset)
self.assertEquals(expected, result)
开发者ID:altai,项目名称:altai-api,代码行数:30,代码来源:test_collection_projects.py
示例11: setUp
def setUp(self):
super(AddProjectUserTestCase, self).setUp()
self.project_id = u'PID'
self.user_id = u'UID'
self.tenant = doubles.make(self.mox, doubles.Tenant,
id=self.project_id)
self.user = doubles.make(self.mox, doubles.User,
id=self.user_id, name='username')
开发者ID:altai,项目名称:altai-api,代码行数:8,代码来源:test_collection_project_users.py
示例12: setUp
def setUp(self):
super(AddFwRuleSetToVMTestCase, self).setUp()
self.mox.StubOutWithMock(ifwrs, 'client_set_for_tenant')
self.mox.StubOutWithMock(ifwrs, 'link_for_security_group')
self.server = doubles.make(self.mox, doubles.Server,
tenant_id='FWPROJECT',
id=u'VMID', name=u'ExampleVM')
self.sg = doubles.make(self.mox, doubles.SecurityGroup,
tenant_id='FWPROJECT',
id=2, name=u'ExampleSG')
self.sg_id = unicode(self.sg.id)
开发者ID:altai,项目名称:altai-api,代码行数:11,代码来源:test_collection_vm_fw_rule_sets.py
示例13: test_current_user_project_ids
def test_current_user_project_ids(self):
tenants = [doubles.make(self.mox, doubles.Tenant, id='PID1'),
doubles.make(self.mox, doubles.Tenant, id='PID2')]
self.fake_client_set.identity_public.tenants.list() \
.AndReturn(tenants)
self.mox.ReplayAll()
with self.app.test_request_context():
self.install_fake_auth()
ids = auth.current_user_project_ids()
self.assertEquals(ids, set(('PID1', 'PID2')))
开发者ID:altai,项目名称:altai-api,代码行数:11,代码来源:test_auth.py
示例14: setUp
def setUp(self):
super(UserFetchesUserTestCase, self).setUp()
self.mox.StubOutWithMock(users.auth, 'admin_client_set')
self.mox.StubOutWithMock(users.auth, 'current_user_id')
self.mox.StubOutWithMock(users.auth, 'current_user_project_ids')
self.user = doubles.make(self.mox, doubles.User,
id='UID', name='Test')
self.role = doubles.make(self.mox, doubles.Role,
tenant={'id': 'PID'},
id='ROLE', name='Role')
self.admin_cs = self._fake_client_set_factory()
开发者ID:altai,项目名称:altai-api,代码行数:11,代码来源:test_collection_users.py
示例15: setUp
def setUp(self):
super(ImagesAsUserTestCase, self).setUp()
self.mox.StubOutWithMock(images.auth, "client_set_for_tenant")
self.mox.StubOutWithMock(images.auth, "default_tenant_id")
self.mox.StubOutWithMock(images.auth, "current_user_project_ids")
self.mox.StubOutWithMock(images, "_image_to_view")
self.tenant = doubles.make(self.mox, doubles.Tenant, id="PID", name="ptest")
self.images = [
doubles.make(self.mox, doubles.Image, id="IMAGE1", owner="SYS"),
doubles.make(self.mox, doubles.Image, id="IMAGE2", owner="PID"),
doubles.make(self.mox, doubles.Image, id="IMAGE3", owner="PID"),
]
开发者ID:altai,项目名称:altai-api,代码行数:12,代码来源:test_collection_images.py
示例16: test_servers_for_user_none
def test_servers_for_user_none(self):
self.mox.StubOutWithMock(instances, 'client_set_for_tenant')
tenants = [doubles.make(self.mox, doubles.Tenant, id='P2'),
doubles.make(self.mox, doubles.Tenant, id='P3')]
self.fake_client_set.identity_public.tenants.list() \
.AndReturn(tenants)
self.mox.ReplayAll()
with self.app.test_request_context('/v1/instances?my-projects=true'
'&project:eq=P1'):
self.install_fake_auth()
instances.parse_collection_request(instances._SCHEMA.sortby)
result = instances._servers_for_user()
self.assertEquals(result, [])
开发者ID:altai,项目名称:altai-api,代码行数:13,代码来源:test_collection_vms.py
示例17: test_bound_client_user
def test_bound_client_user(self):
# pretend we have unbound client set:
self.fake_client_set.http_client.access['user']['roles'] = []
tenants = [doubles.make(self.mox, doubles.Tenant, id='PID1'),
doubles.make(self.mox, doubles.Tenant, id='PID2')]
self.fake_client_set.identity_public.tenants.list() \
.AndReturn(tenants)
auth.client_set_for_tenant('PID1').AndReturn('FAKE_CS')
self.mox.ReplayAll()
with self.app.test_request_context():
self.install_fake_auth()
self.assertEquals(auth.bound_client_set(), 'FAKE_CS')
开发者ID:altai,项目名称:altai-api,代码行数:14,代码来源:test_auth.py
示例18: test_get_one
def test_get_one(self):
flavors = [
doubles.make(self.mox, doubles.Flavor, id="42111"),
doubles.make(self.mox, doubles.Flavor, id="42"),
doubles.make(self.mox, doubles.Flavor, id="421"),
]
self.fake_client_set.compute.flavors.list().AndReturn(flavors)
instance_types._instance_type_to_view(flavors[1]).AndReturn('REPLY')
self.mox.ReplayAll()
rv = self.client.get('/v1/instance-types/42')
data = self.check_and_parse_response(rv)
self.assertEquals(data, 'REPLY')
开发者ID:altai,项目名称:altai-api,代码行数:14,代码来源:test_collection_instance_types.py
示例19: test_rule_object_to_view_works
def test_rule_object_to_view_works(self):
rule = doubles.make(self.mox, doubles.SecurityGroupRule,
**self.to_view)
self.mox.ReplayAll()
with self.app.test_request_context():
res = fw_rules._fw_rule_object_to_view(rule)
self.assertEquals(res, self.expected)
开发者ID:altai,项目名称:altai-api,代码行数:7,代码来源:test_collection_fw_rules.py
示例20: setUp
def setUp(self):
super(DeleteProjectTestCase, self).setUp()
self.tenant_id = u'PID'
self.tenant = doubles.make(self.mox, doubles.Tenant,
id=self.tenant_id)
self.mox.StubOutWithMock(projects, '_project_has_servers')
self.mox.StubOutWithMock(projects, '_project_has_images')
开发者ID:altai,项目名称:altai-api,代码行数:7,代码来源:test_collection_projects.py
注:本文中的tests.doubles.make函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论