def test_doNotAddItemWhenNoItemToAdd(self):
     toTracker = mock()
     fromTracker = mock()
     when(fromTracker).items(any()).thenReturn([])
     syncByAddingItems = TrackerSyncBy.addingItemsOfType(None)
     syncByAddingItems(fromTracker, toTracker)
     verify(toTracker, never).update()
 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) 
 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)
 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)
 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
 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)
 def test_doNotAddItemWhenNoItemToAdd(self):
     toTracker = mock()
     fromTracker = mock()
     when(fromTracker).items(any()).thenReturn([])
     syncByAddingItems = TrackerSyncBy.addingItemsOfType(None)
     syncByAddingItems(fromTracker, toTracker)
     verify(toTracker, never).update()
Esempio n. 8
0
 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)
 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
Esempio n. 10
0
 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)
 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
 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)
Esempio n. 13
0
    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)
 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])
 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
Esempio n. 16
0
    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)
 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
 def test_commentsNotAddedIfItemIsNotTheSame(self):
     toTracker = mock()
     item = mock()
     otherItem = mock()
     syncCommentsFor = TrackerSyncBy.syncingItem()
     when(toTracker).items(None).thenReturn(Testing.MockIterator([item]))
     when(item).canBeSyncedWith(otherItem).thenReturn(False)
     syncCommentsFor(otherItem, toTracker)
     verify(item, never).syncWith(any())
     verify(toTracker, never).update(item)
 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()
 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()
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
 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])
 def test_commentsNotAddedIfItemIsNotTheSame(self):
     toTracker = mock()
     item = mock()
     otherItem = mock()
     syncCommentsFor = TrackerSyncBy.syncingItem()
     when(toTracker).items(None).thenReturn(Testing.MockIterator([item]))
     when(item).canBeSyncedWith(otherItem).thenReturn(False)
     syncCommentsFor(otherItem, toTracker)
     verify(item, never).syncWith(any())
     verify(toTracker, never).update(item)
 def test_dontDeleteNotAddedItem(self):
     jira = JiraTracker()
     jiraInstance = self.getMockFor(jira)
     jira.selectProject([])
     jiraTrackerItem = mock()
     story = mock()
     when(jiraTrackerItem).underlying().thenReturn(story)
     when(story).GetStoryId().thenReturn(None)
     jira.delete(jiraTrackerItem)
     verify(jiraInstance.service, never).DeleteStory(any())
     pass 
 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()
 def test_trackerCanAddItem(self):
     tracker = self.makeValidTracker()
     trackerInstance = self.trackerInstance_
     pivotalTrackerItem = mock()
     story = mock()
     when(pivotalTrackerItem).decoratedStory().thenReturn(story)
     when(pivotalTrackerItem).Id().thenReturn(None)
     when(trackerInstance).AddNewStory(any()).thenReturn(mock())
     when(pivotalTrackerItem).comments('new').thenReturn([])
     tracker.update(pivotalTrackerItem)
     verify(trackerInstance).AddNewStory(story)
     pass
 def test_doNotAddUnnecessaryComments(self):
     toTracker = mock()
     item = mock()
     testFilter = mock()
     otherItem = mock()
     syncCommentsFor = TrackerSyncBy.syncingItem(FilteringOutCommentsFor=testFilter.calledWith)
     when(toTracker).items(None).thenReturn(Testing.MockIterator([item]))
     when(item).canBeSyncedWith(otherItem).thenReturn(True)
     when(item).updatedAt().thenReturn(0)
     when(otherItem).updatedAt().thenReturn(1)
     syncCommentsFor(otherItem, toTracker)
     verify(testFilter).calledWith(item)
 def test_addCommentsAndUpdateIssue(self):
     toTracker = mock()
     itemToAddCommentsTo = mock()
     itemToGetCommentsFrom = mock() 
     syncCommentsFor = TrackerSyncBy.syncingItem()
     when(toTracker).items(None).thenReturn(Testing.MockIterator([itemToAddCommentsTo]))
     when(itemToAddCommentsTo).canBeSyncedWith(itemToGetCommentsFrom).thenReturn(True)
     when(itemToAddCommentsTo).updatedAt().thenReturn(0)
     when(itemToGetCommentsFrom).updatedAt().thenReturn(1)
     syncCommentsFor(itemToGetCommentsFrom, toTracker)
     verify(itemToAddCommentsTo).syncWith(itemToGetCommentsFrom)
     verify(toTracker).update(itemToAddCommentsTo)
 def test_trackerCanAddItem(self):
     tracker = self.makeValidTracker()
     trackerInstance = self.trackerInstance_
     pivotalTrackerItem = mock()
     story = mock()
     when(pivotalTrackerItem).decoratedStory().thenReturn(story)
     when(pivotalTrackerItem).Id().thenReturn(None)
     when(trackerInstance).AddNewStory(any()).thenReturn(mock())
     when(pivotalTrackerItem).comments('new').thenReturn([])
     tracker.update(pivotalTrackerItem)
     verify(trackerInstance).AddNewStory(story)
     pass
 def test_filterFunctionIsUsed(self):
     toTracker = mock()
     fromTracker = mock()
     detectedItem = mock()
     filterValue = "filter"
     filterFunction = mock()
     when(fromTracker).items(any()).thenReturn([detectedItem])
     when(toTracker).items(filterValue).thenReturn(Testing.MockIterator([detectedItem]))
     when(filterFunction).calledWith(detectedItem).thenReturn(filterValue)
     when(detectedItem).canBeSyncedWith(detectedItem).thenReturn(True)
     syncByAddingItems = TrackerSyncBy.addingItemsOfType(None, filterFunction.calledWith)
     syncByAddingItems(fromTracker, toTracker)
     verify(toTracker).items(filterValue)
 def test_doNotAddUnnecessaryComments(self):
     toTracker = mock()
     item = mock()
     testFilter = mock()
     otherItem = mock()
     syncCommentsFor = TrackerSyncBy.syncingItem(
         FilteringOutCommentsFor=testFilter.calledWith)
     when(toTracker).items(None).thenReturn(Testing.MockIterator([item]))
     when(item).canBeSyncedWith(otherItem).thenReturn(True)
     when(item).updatedAt().thenReturn(0)
     when(otherItem).updatedAt().thenReturn(1)
     syncCommentsFor(otherItem, toTracker)
     verify(testFilter).calledWith(item)
 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()
Esempio n. 33
0
 def test_mode_executed_with_multiple_commands(self):
     cli = self.makeCli()
     testMode = Mode(cli)
     command1 = mock()
     command2 = mock()
      
     testMode.execute([
             command1,
             command2
             ])
  
     verify(command1).executeOn(cli)
     verify(command2).executeOn(cli)
 def test_canSetPassword(self):
     jira = JiraTracker()
     jiraApiObject = mock()
     jiraInstance = Holder()
     jiraInstance.service = mock()
     jira.apiObject(jiraApiObject)
     password = "******"
     auth = mock()
     when(jiraApiObject).Client(any(), timeout=any()).thenReturn(jiraInstance)
     when(jiraInstance.service).login(any(),any()).thenReturn(auth)
     jira.withCredential(password)
     verify(jiraInstance.service).login(any(),password)
     pass
 def test_canUpdateExistingStory(self):
     tracker = self.makeValidTracker()
     trackerInstance = self.trackerInstance_
     pivotalTrackerItem = mock()
     story = mock()
     storyId = 12345
     when(pivotalTrackerItem).decoratedStory().thenReturn(story)
     when(pivotalTrackerItem).Id().thenReturn(storyId)
     when(trackerInstance).AddNewStory(any()).thenReturn(mock())
     when(pivotalTrackerItem).comments('new').thenReturn([])
     when(trackerInstance).UpdateStory(any()).thenReturn(mock())
     tracker.update(pivotalTrackerItem)
     verify(trackerInstance).UpdateStory(story)
     pass
 def test_addCommentsAndUpdateIssue(self):
     toTracker = mock()
     itemToAddCommentsTo = mock()
     itemToGetCommentsFrom = mock()
     syncCommentsFor = TrackerSyncBy.syncingItem()
     when(toTracker).items(None).thenReturn(
         Testing.MockIterator([itemToAddCommentsTo]))
     when(itemToAddCommentsTo).canBeSyncedWith(
         itemToGetCommentsFrom).thenReturn(True)
     when(itemToAddCommentsTo).updatedAt().thenReturn(0)
     when(itemToGetCommentsFrom).updatedAt().thenReturn(1)
     syncCommentsFor(itemToGetCommentsFrom, toTracker)
     verify(itemToAddCommentsTo).syncWith(itemToGetCommentsFrom)
     verify(toTracker).update(itemToAddCommentsTo)
 def test_canUpdateExistingStory(self):
     tracker = self.makeValidTracker()
     trackerInstance = self.trackerInstance_
     pivotalTrackerItem = mock()
     story = mock()
     storyId = 12345
     when(pivotalTrackerItem).decoratedStory().thenReturn(story)
     when(pivotalTrackerItem).Id().thenReturn(storyId)
     when(trackerInstance).AddNewStory(any()).thenReturn(mock())
     when(pivotalTrackerItem).comments('new').thenReturn([])
     when(trackerInstance).UpdateStory(any()).thenReturn(mock())
     tracker.update(pivotalTrackerItem)
     verify(trackerInstance).UpdateStory(story)
     pass
 def test_whenMultipleItemsMatchFilterAndItemCanBeSyncedWithThenDoNotAddNewItem(self):
     toTracker = mock()
     fromTracker = mock()
     detectedItem = mock()
     TrackerItemType = mock()
     itemToBeAdded = mock()
     when(fromTracker).items(any()).thenReturn([detectedItem])
     when(toTracker).items(any()).thenReturn(Testing.MockIterator([detectedItem,detectedItem]))
     when(detectedItem).canBeSyncedWith(detectedItem).thenReturn(False)
     when(TrackerItemType).called().thenReturn(itemToBeAdded)
     when(toTracker).update(itemToBeAdded).thenReturn(itemToBeAdded)
     syncByAddingItems = TrackerSyncBy.addingItemsOfType(TrackerItemType.called)
     syncByAddingItems(fromTracker, toTracker)
     verify(toTracker, times=2).update(itemToBeAdded)
 def test_filterFunctionIsUsed(self):
     toTracker = mock()
     fromTracker = mock()
     detectedItem = mock()
     filterValue = "filter"
     filterFunction = mock()
     when(fromTracker).items(any()).thenReturn([detectedItem])
     when(toTracker).items(filterValue).thenReturn(
         Testing.MockIterator([detectedItem]))
     when(filterFunction).calledWith(detectedItem).thenReturn(filterValue)
     when(detectedItem).canBeSyncedWith(detectedItem).thenReturn(True)
     syncByAddingItems = TrackerSyncBy.addingItemsOfType(
         None, filterFunction.calledWith)
     syncByAddingItems(fromTracker, toTracker)
     verify(toTracker).items(filterValue)
Esempio n. 40
0
    def test_get_children_default_watcher(self):
        watcher = mock()
        z = pookeeper.allocate(self.hosts, watcher=watcher)

        z.create('/pookie', CREATOR_ALL_ACL, Persistent(), data=_random_data())
        z.get_children('/pookie', watch=True)

        z.create('/pookie/bear', CREATOR_ALL_ACL, Persistent(), data=_random_data())
        z.get_children('/pookie', watch=True)

        z.set_data('/pookie', _random_data())
        z.set_data('/pookie/bear', _random_data())

        # One is for when we do and the other is for when we don't chroot
        z.get_children('/pookie', watch=True)
        z.get_children('/pookie/bear', watch=True)

        z.delete('/pookie/bear')
        z.delete('/pookie')

        z.close()

        mockito.verify(watcher).session_connected(matchers.any(long), matchers.any(str), False)
        mockito.verify(watcher, times=2).children_changed('/pookie')
        mockito.verify(watcher).node_deleted('/pookie/bear')
        mockito.verify(watcher).connection_closed()
        verifyNoMoreInteractions(watcher)
Esempio n. 41
0
 def test_should_return_empty_running_environment_if_nothing_is_running(self):
     mock_command_helper = mock()
     when(mock_command_helper).run_command("sudo lxc-ls -c1").thenReturn("")
     provider = LXCNodeProvider(None, None, mock_command_helper)
     environment = provider.get_running_environment("test", "test", all_credentials)
     self.assertIsNotNone(environment)
     self.assertEqual(0, len(environment.get_locations()))
Esempio n. 42
0
def test_CanRetrieveOrganizationListFiltered():
    pertinoSdk, _, response = setupSdk()
    json = {"orgs": [{"name": "organization", "id": 1234}]}
    when(response).json().thenReturn(json)
    closure = mock()
    pertinoSdk.listOrgs(closure=closure.function)
    verify(closure).function(json["orgs"][0])
def test_CanRetrieveOrganizationListFiltered():
    pertinoSdk, _, response = setupSdk()
    json = {"orgs": [{"name": "organization", "id": 1234}]}
    when(response).json().thenReturn(json)
    closure = mock()
    pertinoSdk.listOrgs(closure=closure.function)
    verify(closure).function(json["orgs"][0])
def test_CanRetrieveDevicesListFiltered():
    pertinoSdk, _, response = setupSdk()
    json = {"devices": [{"ipv4Address": "123.456.789.10", "hostName": "host", "id": 1234}]}
    when(response).json().thenReturn(json)
    closure = mock()
    pertinoSdk.listDevicesIn({"id":1}, closure.function)
    verify(closure).function(json["devices"][0])
def create_node():
    node = mock()
    when(node).id().thenReturn("id")
    when(node).tags().thenReturn({})
    when(node).state().thenReturn('running')
    when(node).address().thenReturn(DynamicDictionary({'dns_name': 'dns_name'}))
    return node
Esempio n. 46
0
 def test_whenSeedingWithPivotalStatus(self):
     pivotalStatus = "Started"
     mapObject = mock()
     status = TrackerItemStatus(pivotalStatus, apiObject=mapObject)
     status.jira()
     verify(mapObject).translateStatusTo('jira', pivotalStatus)
     self.assertEqual(status.pivotal(), pivotalStatus) 
 def test_whenNoActionAvaiableDoNotSetStatus(self):
     jira = JiraTracker()
     jiraInstance = self.getMockFor(jira)
     trackerItem = mock()
     tracerBullet = "hello"
     when(trackerItem).underlying().thenReturn(tracerBullet)
     bullet = jira._ticketWithUpdatedStatusFrom(trackerItem)
     self.assertEqual(tracerBullet, bullet)
 def test_filterAndOmitPivotalTrackerCreateCommentsRemovesComments(self):
     item = mock()
     comments = [
         "A Pivotal Tracker story",
     ]
     when(item).comments("new").thenReturn(comments)
     andOmitPivotalTrackerCreatedComments(item)
     self.assertListEqual(comments, [])
 def test_whenMultipleItemsMatchFilterAndItemCanBeSyncedWithThenDoNotAddNewItem(
         self):
     toTracker = mock()
     fromTracker = mock()
     detectedItem = mock()
     TrackerItemType = mock()
     itemToBeAdded = mock()
     when(fromTracker).items(any()).thenReturn([detectedItem])
     when(toTracker).items(any()).thenReturn(
         Testing.MockIterator([detectedItem, detectedItem]))
     when(detectedItem).canBeSyncedWith(detectedItem).thenReturn(False)
     when(TrackerItemType).called().thenReturn(itemToBeAdded)
     when(toTracker).update(itemToBeAdded).thenReturn(itemToBeAdded)
     syncByAddingItems = TrackerSyncBy.addingItemsOfType(
         TrackerItemType.called)
     syncByAddingItems(fromTracker, toTracker)
     verify(toTracker, times=2).update(itemToBeAdded)
 def test_dontDeleteNotAddedItem(self):
     tracker = self.makeValidTracker()
     trackerInstance = self.trackerInstance_
     pivotalTrackerItem = mock()
     when(pivotalTrackerItem).Id().thenReturn(None)
     tracker.delete(pivotalTrackerItem)
     verify(trackerInstance, never).DeleteStory(any())
     pass
 def test_whenSeedingWithUserForPivotal(self):
     pivotalUser = "******"
     jiraUser = "******"
     mapObject = mock()
     when(mapObject).translateUserTo('jira',
                                     pivotalUser).thenReturn(jiraUser)
     userObject = PivotalUser(pivotalUser, apiObject=mapObject)
     self.assertEqual(pivotalUser, userObject.pivotal())
     self.assertEqual(jiraUser, userObject.jira())
 def jiraTimezoneSetupForTimeStamp(self, timeStamp, daylightTimeHappening):
     time = mock()
     when(time).timezone().thenReturn(25200)
     when(time).daylight().thenReturn(daylightTimeHappening)
     when(time).altzone().thenReturn(21600)
     when(time).mktime(any()).thenReturn(timeStamp)
     timeAsStructure = localtime(timeStamp)
     when(time).localtime(timeStamp).thenReturn(timeAsStructure)
     return time
Esempio n. 53
0
 def test_canCopyItemSpecificDataToAnotherItem(self):
     modified = mock()
     testIssue = self.testIssue()
     testIssueUrl = "http://www.jira.com/browse/TEST-12345"
     source = JiraTrackerItem(testIssue)
     source.withJiraUrl(testIssueUrl)
     source.copyTypeSpecificDataTo(modified)
     verify(modified).withJiraKey(testIssue.key)
     verify(modified).withJiraUrl(testIssueUrl)
Esempio n. 54
0
 def test_canOverwriteKnownReporter(self):
     item = JiraTrackerItem()
     withReporter = "reporter"
     load = self.create_loader(JiraTrackerItem.withRequestor)
     load(item, withReporter)
     random = mock()
     when(random).jira().thenReturn("blah")
     item.withRequestor(random)
     self.assertEqual(random, item.requestor())