本文整理汇总了Python中managers.mapper_manager.MapperManager.update方法的典型用法代码示例。如果您正苦于以下问题:Python MapperManager.update方法的具体用法?Python MapperManager.update怎么用?Python MapperManager.update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类managers.mapper_manager.MapperManager
的用法示例。
在下文中一共展示了MapperManager.update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_update_with_command
# 需要导入模块: from managers.mapper_manager import MapperManager [as 别名]
# 或者: from managers.mapper_manager.MapperManager import update [as 别名]
def test_update_with_command(self, many_test_data, monkeypatch, session):
obj_class = many_test_data['class']
if obj_class in [Command]:
return
workspace = WorkspaceFactory.create(name='test')
command = CommandFactory.create(workspace=workspace)
session.add(command)
session.commit()
mapper_manager = MapperManager()
mapper_manager.createMappers(workspace.name)
test_data = many_test_data
raw_data = test_data['data']
if test_data['parent']:
parent = test_data['parent']['parent_factory'].create()
session.add(parent)
session.commit()
test_data['data']['parent'] = parent.id
test_data['data']['parent_type'] = test_data['parent']['parent_type']
test_data['expected_payload']['parent'] = parent.id
if obj_class in [Vuln, Credential]:
test_data['expected_payload']['parent_type'] = test_data['parent']['parent_type']
relational_model = test_data['factory'].create()
session.add(relational_model)
session.commit()
def mock_server_put(put_url, update=False, expected_response=201, **params):
assert put_url == '{0}/ws/test/{1}/{2}/?command_id={3}'.format(
_create_server_api_url(),
test_data['api_end_point'],
test_data['id'],
params['command_id'])
assert expected_response == 200
assert update == False
return {
'id': 1,
'ok': True,
'rev': ''
}
raw_data['id'] = relational_model.id
test_data['id'] = relational_model.id
monkeypatch.setattr(persistence.server.server, '_put', mock_server_put)
obj = obj_class(raw_data, workspace.name)
mapper_manager.update(obj, command.id)
示例2: test_update_without_command
# 需要导入模块: from managers.mapper_manager import MapperManager [as 别名]
# 或者: from managers.mapper_manager.MapperManager import update [as 别名]
def test_update_without_command(self, many_test_data, monkeypatch, session):
obj_class = many_test_data['class']
workspace = WorkspaceFactory.create(name='test')
mapper_manager = MapperManager()
mapper_manager.createMappers(workspace.name)
test_data = many_test_data
relational_model = test_data['factory'].create()
session.add(relational_model)
session.commit()
raw_data = test_data['data']
if test_data['parent']:
parent = test_data['parent']['parent_factory'].create()
session.add(parent)
session.commit()
test_data['data']['parent'] = parent.id
test_data['data']['parent_type'] = test_data['parent']['parent_type']
if obj_class not in [Note, Command]:
test_data['expected_payload']['parent'] = parent.id
if obj_class in [Vuln, Credential]:
test_data['expected_payload']['parent_type'] = test_data['parent']['parent_type']
def mock_server_put(test_data, put_url, update=False, expected_response=201, **params):
assert put_url == '{0}/ws/test/{1}/{2}/'.format(_create_server_api_url(), test_data['api_end_point'], test_data['id'])
assert expected_response == 200
assert update == False
if obj_class not in [Command]:
metadata = params.pop('metadata')
assert metadata['owner'] == test_data['expected_payload']['owner']
params.pop('command_id', None)
test_data['expected_payload'].pop('command_id', None)
assert params == test_data['expected_payload']
return {
'id': 1,
'ok': True,
'rev': ''
}
raw_data['id'] = relational_model.id
test_data['id'] = relational_model.id
monkeypatch.setattr(persistence.server.server, '_put', partial(mock_server_put, test_data))
obj = obj_class(raw_data, workspace.name)
mapper_manager.update(obj)