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


Python mocking.mock函数代码示例

本文整理汇总了Python中mockito.mocking.mock函数的典型用法代码示例。如果您正苦于以下问题:Python mock函数的具体用法?Python mock怎么用?Python mock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了mock函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_onlyTakeCommentsFromIssueForByFilter

 def test_onlyTakeCommentsFromIssueForByFilter(self):
     toTracker = mock()
     aTestItemFilter = mock()
     syncCommentsFor = TrackerSyncBy.syncingItem(aTestItemFilter.calledWith)
     when(toTracker).items(None).thenRaise(StopIteration)
     syncCommentsFor(None, toTracker)
     verify(aTestItemFilter).calledWith(None)
开发者ID:lwoydziak,项目名称:pivotal-tracker-syncing,代码行数:7,代码来源:trackersyncby_test.py

示例2: test_doNotAddCommentsWhenItemNotFound

 def test_doNotAddCommentsWhenItemNotFound(self):
     toTracker = mock()
     item = mock()
     syncCommentsFor = TrackerSyncBy.syncingItem()
     when(toTracker).items(None).thenRaise(StopIteration)
     syncCommentsFor(item, toTracker)
     verify(toTracker, never).update(item) 
开发者ID:lwoydziak,项目名称:pivotal-tracker-syncing,代码行数:7,代码来源:trackersyncby_test.py

示例3: test_whenJiraIdIsZeroNameIsNone

 def test_whenJiraIdIsZeroNameIsNone(self):
     jiraStatus = mock()
     mapObject = mock()
     when(jiraStatus).status().thenReturn("")
     status = TrackerItemStatus(jiraStatus, mapObject)
     verify(mapObject, never).translateStatusTo(any(), any())
     self.assertEqual(status.jira(), None)
开发者ID:lwoydziak,项目名称:pivotal-tracker-syncing,代码行数:7,代码来源:trackeritemstatus_test.py

示例4: setupSync

 def setupSync(self, syncDirection=ForwardSync):
     toTracker = mock()
     itemToSyncTo = mock()
     itemToSyncFrom = mock()
     syncCommentsFor = TrackerSyncBy.syncingItem(Direction=syncDirection)
     when(toTracker).items(None).thenReturn(Testing.MockIterator([itemToSyncTo]))
     return toTracker, itemToSyncTo, itemToSyncFrom, syncCommentsFor
开发者ID:lwoydziak,项目名称:pivotal-tracker-syncing,代码行数:7,代码来源:trackersyncby_test.py

示例5: test_doNotAddItemWhenNoItemToAdd

 def test_doNotAddItemWhenNoItemToAdd(self):
     toTracker = mock()
     fromTracker = mock()
     when(fromTracker).items(any()).thenReturn([])
     syncByAddingItems = TrackerSyncBy.addingItemsOfType(None)
     syncByAddingItems(fromTracker, toTracker)
     verify(toTracker, never).update()
开发者ID:lwoydziak,项目名称:pivotal-tracker-syncing,代码行数:7,代码来源:trackersyncby_test.py

示例6: test_whenStatusCanBeMatchedToActionThenReturnActionId

 def test_whenStatusCanBeMatchedToActionThenReturnActionId(self):
     status = mock()
     potentialAction = mock()
     actions = [potentialAction, ]
     when(status).jira().thenReturn([str(potentialAction.name)])
     action = JiraStatusToAction(status, actions)
     self.assertEqual(str(potentialAction.id), str(action.Id()))
     pass
开发者ID:lwoydziak,项目名称:pivotal-tracker-syncing,代码行数:8,代码来源:jirastatustoaction_test.py

示例7: test_canConvertItemToType

 def test_canConvertItemToType(self):
     tracker = Tracker()
     contents = mock()
     timezone = mock()
     item = tracker._convertToItem(testType, contents, timezone )
     storedItem, storedTimezone = item.contains()
     self.assertEqual(storedItem, contents)
     self.assertEqual(storedTimezone, timezone)
开发者ID:lwoydziak,项目名称:pivotal-tracker-syncing,代码行数:8,代码来源:tracker_test.py

示例8: test_should_not_throw_exception_when_node_is_up_and_running

    def test_should_not_throw_exception_when_node_is_up_and_running(self):
        mock_command_helper = mock()
        mock_string_attr = mock()
        mock_string_attr.succeeded=True
        lxc_node = LXCNode("123", mock_command_helper, "test_host_name")

        when(mock_command_helper).run_command_silently("ping -c1 123").thenReturn(mock_string_attr)

        lxc_node.wait_for_ready(lambda : None, 15)
开发者ID:ThoughtWorksInc,项目名称:Phoenix,代码行数:9,代码来源:lxc_provider_test.py

示例9: setupStatus

 def setupStatus(self): 
     jira = JiraTracker()
     jiraInstance = self.getMockFor(jira)
     itemId = 1234
     trackerItem = mock()
     status = mock()
     when(trackerItem).Id().thenReturn(itemId)
     when(trackerItem).status().thenReturn(status)
     return jira, jiraInstance, itemId, trackerItem, status
开发者ID:lwoydziak,项目名称:pivotal-tracker-syncing,代码行数:9,代码来源:jiratracker_test.py

示例10: test_should_throw_exception_when_node_is_not_up_and_running

    def test_should_throw_exception_when_node_is_not_up_and_running(self):
        mock_command_helper = mock()
        mock_string_attr = mock()
        mock_string_attr.succeeded=False
        lxc_node = LXCNode("123", mock_command_helper, "test_host_name")

        when(mock_command_helper).run_command_silently("ping -c1 123").thenReturn(mock_string_attr)
        with self.assertRaisesRegexp(Exception, "Node 123 is not running"):
            lxc_node.wait_for_ready(lambda : None, 5)
开发者ID:ThoughtWorksInc,项目名称:Phoenix,代码行数:9,代码来源:lxc_provider_test.py

示例11: test_rightItemReturnedWhenMoreThanOneItemReturnedForReverseSync

 def test_rightItemReturnedWhenMoreThanOneItemReturnedForReverseSync(self):
     toTracker = mock()
     items = [mock(), mock(), mock()]
     when(toTracker).items(any()).thenReturn(Testing.MockIterator([items[1],items[2]]))
     when(items[1]).canBeSyncedWith(items[0]).thenReturn(False)
     when(items[2]).canBeSyncedWith(items[0]).thenReturn(True)
     forwardSync = ReverseSync(mock().function, items[0], toTracker, None)
     forwardSync.obtainItem()
     verify(items[2]).canBeSyncedWith(items[0])
开发者ID:lwoydziak,项目名称:pivotal-tracker-syncing,代码行数:9,代码来源:trackersyncby_test.py

示例12: getMockFor

 def getMockFor(self, jira):
     jiraApiObject = mock()
     jiraInstance = Holder()
     jiraInstance.service = mock()
     jira.apiObject(jiraApiObject)
     when(jiraApiObject).Client(any(), timeout=any()).thenReturn(jiraInstance)
     self.auth_ = mock()
     when(jiraInstance.service).login(any(),any()).thenReturn(self.auth_)
     jira.withCredential("None")
     return jiraInstance
开发者ID:lwoydziak,项目名称:pivotal-tracker-syncing,代码行数:10,代码来源:jiratracker_test.py

示例13: setupCliProcessingJson

def setupCliProcessingJson(json, password=None):
    cliProcessingJson = CliProcessingJson("garbage", initialJsonString=json)
    UserObject = mock()
    user = mock()
    user.password = password
    CliObject = mock()
    cli = mock()
    when(UserObject).called(any(), any()).thenReturn(user)
    when(CliObject).called(any(), any(), debug=any(), trace=any()).thenReturn(cli)
    return cliProcessingJson, UserObject, CliObject, cli, user
开发者ID:Pertino,项目名称:dynamic_machine,代码行数:10,代码来源:cli_process_json_test.py

示例14: test_whenMultipleItemsMatchFilterAndItemsCanNotBeSyncedWithThenAddNewItem

 def test_whenMultipleItemsMatchFilterAndItemsCanNotBeSyncedWithThenAddNewItem(self):
     toTracker = mock()
     fromTracker = mock()
     detectedItem = mock()
     when(fromTracker).items(any()).thenReturn([detectedItem])
     when(toTracker).items(any()).thenReturn(Testing.MockIterator([detectedItem,detectedItem]))
     when(detectedItem).canBeSyncedWith(detectedItem).thenReturn(False).thenReturn(True)
     syncByAddingItems = TrackerSyncBy.addingItemsOfType(None)
     syncByAddingItems(fromTracker, toTracker)
     verify(toTracker, never).update()
开发者ID:lwoydziak,项目名称:pivotal-tracker-syncing,代码行数:10,代码来源:trackersyncby_test.py

示例15: test_doNotAddItemWhenItemInTracker

 def test_doNotAddItemWhenItemInTracker(self):
     toTracker = mock()
     fromTracker = mock()
     detectedItem = mock()
     when(fromTracker).items(any()).thenReturn([detectedItem])
     when(toTracker).items(any()).thenReturn(Testing.MockIterator([detectedItem]))
     when(detectedItem).canBeSyncedWith(detectedItem).thenReturn(True)
     syncByAddingItems = TrackerSyncBy.addingItemsOfType(None)
     syncByAddingItems(fromTracker, toTracker)
     verify(toTracker, never).update()
开发者ID:lwoydziak,项目名称:pivotal-tracker-syncing,代码行数:10,代码来源:trackersyncby_test.py


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