本文整理汇总了Python中mock.MagicMock.info方法的典型用法代码示例。如果您正苦于以下问题:Python MagicMock.info方法的具体用法?Python MagicMock.info怎么用?Python MagicMock.info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mock.MagicMock
的用法示例。
在下文中一共展示了MagicMock.info方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_add_helping_materials_excel_with_info
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import info [as 别名]
def test_add_helping_materials_excel_with_info(self, auto_mock, find_mock, workbook_mock):
"""Test add_helpingmaterials excel with info field works."""
auto_mock.return_value = (0, None)
project = MagicMock()
project.name = 'name'
project.short_name = 'short_name'
project.description = 'description'
project.info = dict()
project.id = 1
wb = Workbook()
ws = wb.active
headers = ['Column Name', 'foo']
ws.append(headers)
for row in range(2, 10):
ws.append(['value', 'bar'])
ws.append([None, None])
ws.append([None, None])
find_mock.return_value = project
helpingmaterials = MagicMock()
helpingmaterials.read.return_value = wb
workbook_mock.return_value = wb
pbclient = MagicMock()
self.config.pbclient = pbclient
res = _add_helpingmaterials(self.config, helpingmaterials, 'xlsx')
self.config.pbclient.create_helpingmaterial.assert_called_with(project_id=find_mock().id,
info={u'column_name': u'value',
u'foo': u'bar'})
assert res == '8 helping materials added to project: short_name', res
示例2: test_add_tasks_po_from_filextension
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import info [as 别名]
def test_add_tasks_po_from_filextension(self, find_mock, po_mock):
"""Test add_tasks po without specifying file extension works."""
project = MagicMock()
project.name = 'name'
project.short_name = 'short_name'
project.description = 'description'
project.info = dict()
find_mock.return_value = project
entry = MagicMock()
entry.msgid = 'English'
entry.msgtr = ''
po = MagicMock()
po.untranslated_entries.return_value = [entry]
po_mock.return_value = po
tasks = MagicMock()
tasks.name = 'tasks.po'
tasks.read.return_value = json.dumps([{'info': {'msgid': 'English',
'msgtr':''}}])
pbclient = MagicMock()
pbclient.create_task.return_value = {'id': 1, 'info': {'msgid': 'English',
'msgtr': ''}}
self.config.pbclient = pbclient
res = _add_tasks(self.config, tasks, None, 0, 30)
assert res == '1 tasks added to project: short_name', res
示例3: test_update_project_another_error
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import info [as 别名]
def test_update_project_another_error(self, find_mock):
"""Test update_project another error works."""
project = MagicMock()
project.name = 'name'
project.short_name = 'short_name'
project.description = 'description'
project.info = dict()
find_mock.return_value = project
task_presenter = "test/template.html"
results = "test/results.html"
tutorial = "test/tutorial.html"
long_description = "test/long_description.md"
pbclient = MagicMock()
pbclient.update_project.return_value = self.error
self.config.pbclient = pbclient
res = _update_project(self.config, task_presenter, results,
long_description, tutorial)
msg = ("Project not found! The project: short_name is missing." \
" Use the flag --all=1 to search in all the server ")
assert res == msg, msg
示例4: test_install
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import info [as 别名]
def test_install(self):
pkg = pkg_apt.AptPkg(MagicMock(), "foo", {'installed': True})
status = MagicMock()
status.info = {'installed': False}
self.assertEqual(
pkg.ask(status),
"status not installed → installed\n",
)
示例5: test_delete_connection_error
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import info [as 别名]
def test_delete_connection_error(self, find_mock):
"""Test delete tasks connection error works."""
project = MagicMock()
project.name = 'name'
project.short_name = 'short_name'
project.description = 'description'
project.info = dict()
find_mock.return_value = project
pbclient = MagicMock()
pbclient.delete_task.side_effect = exceptions.ConnectionError
self.config.pbclient = pbclient
res = _delete_tasks(self.config, 1)
assert res == "Connection Error! The server http://server is not responding", res
示例6: test_start
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import info [as 别名]
def test_start(self):
svc = svc_upstart.SvcUpstart(MagicMock(), "foo", {'running': True})
status = MagicMock()
status.info = {'running': False}
self.assertEqual(
svc.ask(status),
"status not running → running\n",
)
示例7: test_stop
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import info [as 别名]
def test_stop(self):
svc = svc_systemd.SvcSystemd(MagicMock(), "foo", {'running': False})
status = MagicMock()
status.info = {'running': True}
self.assertEqual(
svc.ask(status),
"status running → not running\n",
)
示例8: test_remove
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import info [as 别名]
def test_remove(self):
pkg = pkg_pacman.PacmanPkg(MagicMock(), "foo", {'installed': False})
status = MagicMock()
status.info = {'installed': True}
self.assertEqual(
pkg.ask(status),
"status installed → not installed\n",
)
示例9: set_element_find_result
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import info [as 别名]
def set_element_find_result(mocks, **uia_attr):
elem = MagicMock()
elem.info = uia_element_info(**uia_attr)
mocks.device.return_value = [elem]
mocks.device.dump.return_value = create_dump_xml(elem.info)
mocks.uiroot.nametowidget(
'sidebar.refresh_button').process_event(None, None)
return elem
示例10: test_add_user_event
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import info [as 别名]
def test_add_user_event(self, mock_update_feed):
"""Test add_user_event is called."""
conn = MagicMock()
target = MagicMock()
target.id = 1
target.project_id = 1
tmp = MagicMock()
tmp.name = "name"
tmp.short_name = "short_name"
tmp.info = dict()
conn.execute.return_value = [tmp]
add_user_event(None, conn, target)
assert mock_update_feed.called
示例11: test_add_blog_event
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import info [as 别名]
def test_add_blog_event(self, mock_queue, mock_update_feed):
"""Test add_blog_event is called."""
conn = MagicMock()
target = MagicMock()
target.id = 1
target.project_id = 1
tmp = MagicMock()
tmp.name = "name"
tmp.short_name = "short_name"
tmp.info = dict()
conn.execute.return_value = [tmp]
add_blog_event(None, conn, target)
mock_queue.enqueue.assert_called_with(notify_blog_users, blog_id=target.id, project_id=target.project_id)
assert mock_update_feed.called
示例12: test_delete_another_error_one_tasks
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import info [as 别名]
def test_delete_another_error_one_tasks(self, find_mock):
"""Test delete tasks another error works for one task."""
project = MagicMock()
project.name = 'name'
project.short_name = 'short_name'
project.description = 'description'
project.info = dict()
find_mock.return_value = project
pbclient = MagicMock()
pbclient.delete_task.return_value = self.error_task
self.config.pbclient = pbclient
assert_raises(TaskNotFound, _delete_tasks, self.config, 1)
示例13: test_delete_task
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import info [as 别名]
def test_delete_task(self, find_mock):
"""Test delete task works."""
project = MagicMock()
project.name = 'name'
project.short_name = 'short_name'
project.description = 'description'
project.info = dict()
find_mock.return_value = project
pbclient = MagicMock()
pbclient.delete_task.return_value = []
self.config.pbclient = pbclient
res = _delete_tasks(self.config, 1)
assert res == "Task.id = 1 and its associated task_runs have been deleted", res
示例14: test_delete_another_error_all_tasks
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import info [as 别名]
def test_delete_another_error_all_tasks(self, find_mock):
"""Test delete tasks another error works for all tasks."""
project = MagicMock()
project.name = 'name'
project.short_name = 'short_name'
project.description = 'description'
project.info = dict()
find_mock.return_value = project
pbclient = MagicMock()
pbclient.delete_task.return_value = self.error
task = MagicMock()
task.id = 1
pbclient.get_tasks.return_value = [task]
self.config.pbclient = pbclient
assert_raises(ProjectNotFound, _delete_tasks, self.config, None)
示例15: test_update_task_redundancy_fails
# 需要导入模块: from mock import MagicMock [as 别名]
# 或者: from mock.MagicMock import info [as 别名]
def test_update_task_redundancy_fails(self, auto_mock, find_mock):
"""Test update task redundancy fails works."""
auto_mock.return_value = (0, None)
project = MagicMock()
project.name = 'name'
project.short_name = 'short_name'
project.description = 'description'
project.info = dict()
find_mock.return_value = project
pbclient = MagicMock()
pbclient.find_tasks.return_value = self.error_task
self.config.pbclient = pbclient
assert_raises(TaskNotFound, _update_tasks_redundancy, self.config,
9999, 5)