本文整理汇总了Python中solum.tests.utils.dummy_context函数的典型用法代码示例。如果您正苦于以下问题:Python dummy_context函数的具体用法?Python dummy_context怎么用?Python dummy_context使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dummy_context函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_upload
def test_upload(self, mock_write_row, mock_trans_jlog, mock_swift,
mock_open):
ctxt = utils.dummy_context()
orig_path = "original path"
assembly = fakes.FakeAssembly()
build_id = "5678"
container = 'fake-container'
cfg.CONF.worker.log_upload_swift_container = container
stage = "fakestage"
swiftupload = uploader.SwiftUpload(ctxt, orig_path,
assembly, build_id,
stage)
resource = swiftupload.resource
swiftupload.upload_log()
swift_info = {'container': container}
filename = "%s-%s/%s-%s.log" % (resource.name,
resource.uuid,
stage, build_id)
self.assertTrue(mock_trans_jlog.called)
tansf_path = orig_path + '.tf'
mock_swift.assert_called_once_with(tansf_path,
container,
filename)
mock_write_row.assert_called_once_with(filename, swift_info)
示例2: test_create
def test_create(self, mock_kc, mock_registry):
data = {'user_id': 'new_user_id',
'uuid': 'input_uuid',
'plan_uuid': 'input_plan_uuid'}
db_obj = fakes.FakePipeline()
mock_registry.Pipeline.return_value = db_obj
fp = fakes.FakePlan()
mock_registry.Plan.get_by_id.return_value = fp
fp.raw_content = {
'name': 'theplan',
'artifacts': [{'name': 'nodeus',
'artifact_type': 'application.heroku',
'content': {
'href': 'https://example.com/ex.git'},
'language_pack': 'auto'}]}
trust_ctx = utils.dummy_context()
trust_ctx.trust_id = '12345'
mock_kc.return_value.create_trust_context.return_value = trust_ctx
handler = pipeline_handler.PipelineHandler(self.ctx)
res = handler.create(data)
db_obj.update.assert_called_once_with(data)
db_obj.create.assert_called_once_with(self.ctx)
self.assertEqual(db_obj, res)
mock_kc.return_value.create_trust_context.assert_called_once_with()
示例3: setUp
def setUp(self):
super(TestWorkflowHandler, self).setUp()
self.ctx = utils.dummy_context()
self.CONF = self.useFixture(config.Config())
self.CONF.config(auth_uri='http://fakeidentity.com',
group=auth.OPT_GROUP_NAME)
self.CONF.config(keystone_version='3')
示例4: setUp
def setUp(self):
super(TestComponent, self).setUp()
self.db = self.useFixture(utils.Database())
self.ctx = utils.dummy_context()
self.data_assembly = [
{'project_id': 'project_id_blah',
'uuid': 'ce43e347f0b0422825245b3e5f140a81cef6e65b',
'user_id': 'fred',
'name': 'assembly1',
'description': 'test assembly',
'trigger_id': 'trigger-uuid-1234',
'tags': 'assembly tags',
'plan_id': 'plan_id_1',
'status': 'Building',
'application_uri': 'http://192.168.78.21:5000'}]
utils.create_models_from_data(assembly.Assembly, self.data_assembly,
self.ctx)
self.data = [{'project_id': 'project_id_blah',
'user_id': 'fred',
'uuid': 'ce43e347f0b0422825245b3e5f140a81cef6e65b',
'name': 'component_no_assembly',
'description': 'test component',
'parent_component_id': '87d98s',
'tags': 'component tags'},
{'project_id': 'project_id_dep',
'user_id': 'fred',
'uuid': '70763488-72e0-44ac-a612-e94bf5488555',
'name': 'component_assembly',
'description': 'test component',
'assembly_uuid': 'ce43e347f0b042282524'
'5b3e5f140a81cef6e65b',
'parent_component_id': '87d98s',
'tags': 'component tags'}]
utils.create_models_from_data(component.Component, self.data, self.ctx)
示例5: test_create
def test_create(self, mock_kc, mock_build, mock_registry):
data = {'user_id': 'new_user_id',
'uuid': 'input_uuid',
'plan_uuid': 'input_plan_uuid'}
db_obj = fakes.FakeAssembly()
mock_registry.Assembly.return_value = db_obj
fp = fakes.FakePlan()
mock_registry.Plan.get_by_id.return_value = fp
fp.raw_content = {
'name': 'theplan',
'artifacts': [{'name': 'nodeus',
'artifact_type': 'heroku',
'content': {
'href': 'https://example.com/ex.git'},
'language_pack': 'auto'}]}
mock_registry.Image.return_value = fakes.FakeImage()
trust_ctx = utils.dummy_context()
trust_ctx.trust_id = '12345'
mock_kc.return_value.create_trust_context.return_value = trust_ctx
handler = assembly_handler.AssemblyHandler(self.ctx)
res = handler.create(data)
db_obj.update.assert_called_once_with(data)
db_obj.create.assert_called_once_with(self.ctx)
self.assertEqual(db_obj, res)
mock_build.assert_called_once_with(
build_id=8, name='nodeus', assembly_id=8,
source_uri='https://example.com/ex.git',
test_cmd=None,
base_image_id='auto', source_format='heroku', image_format='qcow2')
mock_kc.return_value.create_trust_context.assert_called_once_with()
示例6: setUp
def setUp(self):
super(TestExecution, self).setUp()
self.db = self.useFixture(utils.Database())
self.ctx = utils.dummy_context()
self.data = [{'pipeline_id': 'bla',
'uuid': 'ce43e347f0b0422825245b3e5f140a81cef6e65b'}]
utils.create_models_from_data(execution.Execution, self.data, self.ctx)
示例7: test_swift_client_upload_exception
def test_swift_client_upload_exception(self, mock_file_size,
mock_swift_client, mock_open):
ctxt = utils.dummy_context()
mock_file_size.return_value = 0
swift = swiftclient.SwiftClient(ctxt)
self.assertRaises(exc.InvalidObjectSizeError,
swift.upload, 'filepath', 'fake-container', 'fname')
示例8: setUp
def setUp(self):
super(TestPlan, self).setUp()
self.db = self.useFixture(utils.Database())
self.ctx = utils.dummy_context()
self.data = [{'uuid': 'test-uuid-123',
'project_id': 'bla',
'user_id': 'fred',
'raw_content': 'lots of stuff here'}]
utils.create_models_from_data(plan.Plan, self.data, self.ctx)
示例9: test_upload
def test_upload(self):
ctxt = utils.dummy_context()
orig_path = "original path"
assembly_id = "1234"
build_id = "5678"
baseuploader = uploader.UploaderBase(ctxt, orig_path,
assembly_id, build_id,
"fakestage")
self.assertEqual(0, baseuploader.write_userlog_row.call_count)
示例10: setUp
def setUp(self):
super(TestCompilerVersions, self).setUp()
self.db = self.useFixture(utils.Database())
self.ctx = utils.dummy_context()
self.data = [{'uuid': '123456789abcdefghi',
'version': '1.4',
'language_pack_id': 'java1.4'}]
utils.create_models_from_data(lp.CompilerVersions, self.data, self.ctx)
示例11: setUp
def setUp(self):
super(TestImage, self).setUp()
self.db = self.useFixture(utils.Database())
self.ctx = utils.dummy_context()
self.data = [{'project_id': 'test_id',
'user_id': 'fred',
'uuid': '12345678abcdefgh',
'name': 'image1',
'description': 'test image'}]
utils.create_models_from_data(image.Image, self.data, self.ctx)
示例12: setUp
def setUp(self):
super(TestApp, self).setUp()
self.db = self.useFixture(utils.Database())
self.ctx = utils.dummy_context()
self.data = [{'id': 'test-uuid-555',
'project_id': self.ctx.tenant,
'user_id': 'fred',
'name': 'testapp',
'description': 'fake app for testing',
}]
utils.create_models_from_data(app.App, self.data, self.ctx)
示例13: setUp
def setUp(self):
super(KeystoneClientTest, self).setUp()
dummy_url = 'http://server.test:5000/v2.0'
self.ctx = utils.dummy_context()
self.ctx.auth_url = dummy_url
self.ctx.auth_token = 'abcd1234'
self.ctx.auth_token_info = None
cfg.CONF.set_override('www_authenticate_uri', dummy_url,
group='keystone_authtoken')
示例14: setUp
def setUp(self):
super(TestOSPlatform, self).setUp()
self.db = self.useFixture(utils.Database())
self.ctx = utils.dummy_context()
self.data = [{'uuid': '123456789abcdefghi',
'os': 'ubuntu',
'version': '12.04',
'language_pack_id': 'java1.4'}]
utils.create_models_from_data(lp.OSPlatform, self.data, self.ctx)
示例15: setUp
def setUp(self):
super(TestService, self).setUp()
self.db = self.useFixture(utils.Database())
self.ctx = utils.dummy_context()
self.data = [{'project_id': 'fake_project_id',
'user_id': 'fred',
'uuid': '12345678abcdefgh',
'name': 'service1',
'description': 'test service',
'service_type': 'language_pack'}]
utils.create_models_from_data(service.Service, self.data, self.ctx)