本文整理汇总了Python中tests.unit.test.get_test_context函数的典型用法代码示例。如果您正苦于以下问题:Python get_test_context函数的具体用法?Python get_test_context怎么用?Python get_test_context使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_test_context函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
super(AllowSSHContextTestCase, self).setUp()
self.users = 2
self.secgroup_name = "test-secgroup"
self.ctx_with_secgroup = test.get_test_context()
self.ctx_with_secgroup.update({
"users": [
{
"tenant_id": "uuid1",
"endpoint": "endpoint",
"secgroup": {"id": "secgroup_id", "name": "secgroup"}
}
] * self.users,
"admin": {"tenant_id": "uuid2", "endpoint": "admin_endpoint"},
"tenants": {"uuid1": {"id": "uuid1", "name": "uuid1"}},
})
self.ctx_without_secgroup = test.get_test_context()
self.ctx_without_secgroup.update({
"users": [{"tenant_id": "uuid1",
"endpoint": "endpoint"},
{"tenant_id": "uuid1",
"endpoint": "endpoint"}],
"admin": {"tenant_id": "uuid2", "endpoint": "admin_endpoint"},
"tenants": {"uuid1": {"id": "uuid1", "name": "uuid1"}},
})
开发者ID:fdumpling,项目名称:rally,代码行数:26,代码来源:test_allow_ssh.py
示例2: test_dummy_timed_atomic_actions
def test_dummy_timed_atomic_actions(self, mock_interruptable_sleep,
number_of_actions, sleep_factor):
dummy.DummyRandomAction(test.get_test_context()).run(
number_of_actions, sleep_factor)
scenario = dummy.DummyTimedAtomicAction(test.get_test_context())
scenario.run(number_of_actions, sleep_factor)
for i in range(number_of_actions):
self._test_atomic_action_timer(scenario.atomic_actions(),
"action_%d" % i)
mock_interruptable_sleep.assert_any_call(i * sleep_factor)
开发者ID:alinbalutoiu,项目名称:rally,代码行数:10,代码来源:test_dummy.py
示例3: test_setup
def test_setup(self, mock_clients):
containers_per_tenant = 2
objects_per_container = 7
context = test.get_test_context()
context.update({
"config": {
"swift_objects": {
"containers_per_tenant": containers_per_tenant,
"objects_per_container": objects_per_container,
"object_size": 1024,
"resource_management_workers": 10
}
},
"tenants": {
"t1": {"name": "t1_name"},
"t2": {"name": "t2_name"}
},
"users": [
{"id": "u1", "tenant_id": "t1", "endpoint": "e1"},
{"id": "u2", "tenant_id": "t2", "endpoint": "e2"}
]
})
objects_ctx = objects.SwiftObjectGenerator(context)
objects_ctx.setup()
for tenant_id in context["tenants"]:
containers = context["tenants"][tenant_id]["containers"]
self.assertEqual(containers_per_tenant, len(containers))
for container in containers:
self.assertEqual(objects_per_container,
len(container["objects"]))
开发者ID:fdumpling,项目名称:rally,代码行数:32,代码来源:test_objects.py
示例4: test_setup_failure_clients_put_container
def test_setup_failure_clients_put_container(self, mock_clients):
context = test.get_test_context()
context.update({
"config": {
"swift_objects": {
"containers_per_tenant": 2,
"object_size": 10,
"resource_management_workers": 5
}
},
"tenants": {
"t1": {"name": "t1_name"},
"t2": {"name": "t2_name"}
},
"users": [
{"id": "u1", "tenant_id": "t1", "endpoint": "e1"},
{"id": "u2", "tenant_id": "t2", "endpoint": "e2"}
]
})
mock_swift = mock_clients.return_value.swift.return_value
mock_swift.put_container.side_effect = [Exception, True,
Exception, Exception]
objects_ctx = objects.SwiftObjectGenerator(context)
self.assertRaisesRegexp(exceptions.ContextSetupFailure,
"containers, expected 4 but got 1",
objects_ctx.setup)
开发者ID:fdumpling,项目名称:rally,代码行数:26,代码来源:test_objects.py
示例5: setUp
def setUp(self):
super(BaseCustomImageContextVMTestCase, self).setUp()
self.context = test.get_test_context()
self.context.update({
"config": {
"test_custom_image": {
"image": {"name": "image"},
"flavor": {"name": "flavor"},
"username": "fedora",
"floating_network": "floating",
"port": 1022,
}
},
"admin": {
"credential": mock.Mock(),
},
"users": [
{"tenant_id": "tenant_id0"},
{"tenant_id": "tenant_id1"},
{"tenant_id": "tenant_id2"}
],
"tenants": {
"tenant_id0": {},
"tenant_id1": {},
"tenant_id2": {}
}
})
开发者ID:jacobwagner,项目名称:rally,代码行数:28,代码来源:test_custom_image.py
示例6: setUp
def setUp(self):
super(OpenStackScenarioTestCase, self).setUp()
self.osclients = mockpatch.Patch(
"rally.osclients.Clients")
self.useFixture(self.osclients)
self.context = test.get_test_context()
self.context.update({"foo": "bar"})
开发者ID:NaliniKrishna,项目名称:Rally,代码行数:7,代码来源:test_scenario.py
示例7: context_without_edp_keys
def context_without_edp_keys(self):
context = test.get_test_context()
context.update({
"config": {
"users": {
"tenants": self.tenants_num,
"users_per_tenant": self.users_per_tenant,
},
"sahara_edp": {
"input_type": "hdfs",
"output_type": "hdfs",
"input_url": "hdfs://test_host/",
"output_url_prefix": "hdfs://test_host/out_",
"libs": [
{
"name": "test.jar",
"download_url": "http://example.com/test.jar"
}
]
},
},
"admin": {"endpoint": mock.MagicMock()},
"users": self.users_key,
"tenants": self.tenants
})
return context
开发者ID:Pigueiras,项目名称:rally,代码行数:26,代码来源:test_sahara_edp.py
示例8: test__create_containers
def test__create_containers(self, mock_clients):
tenants = 2
containers_per_tenant = 2
context = test.get_test_context()
context.update({
"tenants": {
"1001": {"name": "t1_name"},
"1002": {"name": "t2_name"}
},
"users": [
{"id": "u1", "tenant_id": "1001", "endpoint": "e1"},
{"id": "u2", "tenant_id": "1002", "endpoint": "e2"}
]
})
mixin = utils.SwiftObjectMixin()
containers = mixin._create_containers(context, containers_per_tenant,
15)
self.assertEqual(tenants * containers_per_tenant, len(containers))
for index, container in enumerate(sorted(containers)):
offset = int(index / containers_per_tenant) + 1
self.assertEqual(str(1000 + offset), container[0])
for index, tenant_id in enumerate(sorted(context["tenants"]), start=1):
containers = context["tenants"][tenant_id]["containers"]
self.assertEqual(containers_per_tenant, len(containers))
for container in containers:
self.assertEqual("u%d" % index, container["user"]["id"])
self.assertEqual("e%d" % index, container["user"]["endpoint"])
self.assertEqual(0, len(container["objects"]))
开发者ID:fdumpling,项目名称:rally,代码行数:31,代码来源:test_utils.py
示例9: setUp
def setUp(self):
super(OpenStackScenarioTestCase, self).setUp()
self.osclients = fixtures.MockPatch(
"rally.plugins.openstack.osclients.Clients")
self.useFixture(self.osclients)
self.context = test.get_test_context()
self.context.update({"foo": "bar"})
开发者ID:andreykurilin,项目名称:rally,代码行数:7,代码来源:test_scenario.py
示例10: test_dummy_dummy_with_scenario_output
def test_dummy_dummy_with_scenario_output(self):
scenario = dummy.Dummy(test.get_test_context())
result = scenario.dummy_with_scenario_output()
self.assertEqual(result["errors"], "")
# Since the data is generated in random,
# checking for not None
self.assertIsNotNone(result["data"])
开发者ID:gluke77,项目名称:rally,代码行数:7,代码来源:test_dummy.py
示例11: _gen_context
def _gen_context(self, tenants_count, users_per_tenant,
resources_per_tenant, samples_per_resource):
tenants = self._gen_tenants(tenants_count)
users = []
for id_ in tenants.keys():
for i in range(users_per_tenant):
users.append({"id": i, "tenant_id": id_,
"endpoint": mock.MagicMock()})
context = test.get_test_context()
context.update({
"config": {
"users": {
"tenants": tenants_count,
"users_per_tenant": users_per_tenant,
"concurrent": 10,
},
"ceilometer": {
"counter_name": "fake-counter-name",
"counter_type": "fake-counter-type",
"counter_unit": "fake-counter-unit",
"counter_volume": 100,
"resources_per_tenant": resources_per_tenant,
"samples_per_resource": samples_per_resource
}
},
"admin": {
"endpoint": mock.MagicMock()
},
"users": users,
"tenants": tenants
})
return tenants, context
开发者ID:paboldin,项目名称:rally,代码行数:32,代码来源:test_samples.py
示例12: test_dummy_exception
def test_dummy_exception(self, mock_interruptable_sleep):
scenario = dummy.Dummy(test.get_test_context())
size_of_message = 5
self.assertRaises(dummy.DummyScenarioException,
scenario.dummy_exception, size_of_message, sleep=10)
mock_interruptable_sleep.assert_called_once_with(10)
开发者ID:gluke77,项目名称:rally,代码行数:7,代码来源:test_dummy.py
示例13: test_setup_failure_clients_put_object
def test_setup_failure_clients_put_object(self, mock_clients):
context = test.get_test_context()
context.update({
"tenants": {
"t1": {"name": "t1_name"},
"t2": {"name": "t2_name"}
},
"users": [
{
"id": "u1",
"tenant_id": "t1",
"credential": mock.MagicMock()
},
{
"id": "u2",
"tenant_id": "t2",
"credential": mock.MagicMock()
}
]
})
mock_swift = mock_clients.return_value.swift.return_value
mock_swift.put_object.side_effect = [Exception, True]
objects_ctx = objects.SwiftObjectGenerator(context)
self.assertRaisesRegex(exceptions.ContextSetupFailure,
"objects, expected 2 but got 1",
objects_ctx.setup)
开发者ID:andreykurilin,项目名称:rally,代码行数:26,代码来源:test_objects.py
示例14: get_wrapper
def get_wrapper(self, *skip_cidrs, **kwargs):
mock_clients = mock.Mock()
mock_clients.nova.return_value.networks.list.return_value = [
self.Net(cidr=cidr) for cidr in skip_cidrs]
return network.NovaNetworkWrapper(mock_clients,
test.get_test_context()["task"],
config=kwargs)
开发者ID:Pigueiras,项目名称:rally,代码行数:7,代码来源:test_network.py
示例15: test_dummy
def test_dummy(self, mock_sleep):
scenario = dummy.Dummy(test.get_test_context())
scenario.sleep_between = mock.MagicMock()
scenario.dummy()
self.assertFalse(mock_sleep.sleep.called)
scenario.dummy(sleep=10)
mock_sleep.assert_called_once_with(10)
开发者ID:Pigueiras,项目名称:rally,代码行数:8,代码来源:test_dummy.py
示例16: setUp
def setUp(self):
super(SaharaJobTestCase, self).setUp()
self.context = test.get_test_context()
CONF.set_override("sahara_cluster_check_interval", 0, "benchmark",
enforce_type=True)
CONF.set_override("sahara_job_check_interval", 0, "benchmark",
enforce_type=True)
开发者ID:NaliniKrishna,项目名称:Rally,代码行数:8,代码来源:test_jobs.py
示例17: test_check_random_request
def test_check_random_request(self, mock_choice, mock__check_request):
mock_choice.return_value = {"url": "sample_url"}
Requests = http_requests.HttpRequests(test.get_test_context())
Requests.check_random_request(status_code=200,
requests=[{"url": "sample_url"}])
mock_choice.assert_called_once_with([{"url": "sample_url"}])
mock__check_request.assert_called_once_with(
status_code=200, url="sample_url")
开发者ID:NaliniKrishna,项目名称:Rally,代码行数:8,代码来源:test_http_requests.py
示例18: test__check_request
def test__check_request(self, mock_request):
mock_request.return_value = mock.MagicMock(status_code=200)
scenario = utils.RequestScenario(test.get_test_context())
scenario._check_request(status_code=200, url="sample", method="GET")
self._test_atomic_action_timer(scenario.atomic_actions(),
"requests.check_request")
mock_request.assert_called_once_with("GET", "sample")
开发者ID:hkumarmk,项目名称:rally,代码行数:8,代码来源:test_utils.py
示例19: setUp
def setUp(self):
super(TempestLogWrappersTestCase, self).setUp()
verifier = mock.MagicMock()
verifier.parse_results.return_value = mock.MagicMock(total={"time": 0}, tests={})
context = test.get_test_context()
context.update({"tmp_results_dir": "/tmp/dir", "verifier": verifier})
self.scenario = tempest.TempestScenario(context)
self.scenario._add_atomic_actions = mock.MagicMock()
开发者ID:gwdg,项目名称:rally,代码行数:9,代码来源:test_utils.py
示例20: _get_context
def _get_context():
context = test.get_test_context()
context.update({
"tenant": {
"id": "rally_tenant_id",
"cluster_template": "rally_cluster_template_uuid"
}
})
return context
开发者ID:alinbalutoiu,项目名称:rally,代码行数:9,代码来源:test_clusters.py
注:本文中的tests.unit.test.get_test_context函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论