当前位置: 首页>>代码示例>>Python>>正文


Python MagicMock.info方法代码示例

本文整理汇总了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
开发者ID:PyBossa,项目名称:pbs,代码行数:37,代码来源:test_pbs_add_helping_materials.py

示例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
开发者ID:SkyTruth,项目名称:pbs,代码行数:29,代码来源:test_pbs_add_tasks.py

示例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
开发者ID:PyBossa,项目名称:pbs,代码行数:28,代码来源:test_pbs_update_project.py

示例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",
     )
开发者ID:mfriedenhagen,项目名称:bundlewrap,代码行数:10,代码来源:pkg_apt_tests.py

示例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
开发者ID:PyBossa,项目名称:pbs,代码行数:17,代码来源:test_pbs_delete_tasks.py

示例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",
     )
开发者ID:ntrrgc,项目名称:blockwart,代码行数:10,代码来源:svc_upstart_tests.py

示例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",
     )
开发者ID:ntrrgc,项目名称:blockwart,代码行数:10,代码来源:svc_systemd_tests.py

示例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",
     )
开发者ID:ntrrgc,项目名称:blockwart,代码行数:10,代码来源:pkg_pacman_tests.py

示例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
开发者ID:tksn,项目名称:phoneauto,代码行数:12,代码来源:test_uiactions.py

示例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
开发者ID:chandra1b,项目名称:pybossa,代码行数:15,代码来源:test_event_listeners.py

示例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
开发者ID:chandra1b,项目名称:pybossa,代码行数:16,代码来源:test_event_listeners.py

示例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)
开发者ID:PyBossa,项目名称:pbs,代码行数:16,代码来源:test_pbs_delete_tasks.py

示例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
开发者ID:PyBossa,项目名称:pbs,代码行数:17,代码来源:test_pbs_delete_tasks.py

示例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)
开发者ID:PyBossa,项目名称:pbs,代码行数:19,代码来源:test_pbs_delete_tasks.py

示例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)
开发者ID:PyBossa,项目名称:pbs,代码行数:19,代码来源:test_pbs_update_task_redundancy.py


注:本文中的mock.MagicMock.info方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。