def test_whenTicketNumberInCommentsOfOtherTickerTheRightSyncOccurs(self):
        jira = self.jira_
        pivotal = self.pivotal_
        desiredSummary = "test_whenTicketNumberInCommentsOfOtherTickerTheRightSyncOccurs-1"
        desiredDescription = "overwritten!"
        newJiraItem = jiraItemFactory(Env().get("jira", "project"),
                                      "to be overwritten", "also overwritten")
        self.syncNewItemToPivotal(newJiraItem, jira, pivotal)
        jiraItem = next(jira.items())

        newJiraItem = jiraItemFactory(
            Env().get("jira", "project"),
            "test_whenTicketNumberInCommentsOfOtherTickerTheRightSyncOccurs-2",
            "don't overwrite")
        newJiraItem.addComment(TrackerItemComment(jiraItem.Id()))
        self.syncNewItemToPivotal(newJiraItem, jira, pivotal)

        for item in jira.items():
            jiraItem = item

        jiraItem.withDescription(desiredDescription)
        jiraItem.withSummary(desiredSummary)
        jira.update(jiraItem)

        syncItem = TrackerSyncBy.syncingItem()
        for item in jira.items():
            syncItem(item, toTracker=pivotal)

        for item in pivotal.items():
            updatedPivotalItem = item

        self.assertEqual(updatedPivotalItem.summary(), desiredSummary)
        self.assertEqual(updatedPivotalItem.description(), desiredDescription)
        pass
 def test_whenTicketNumberInCommentsOfOtherTickerTheRightSyncOccurs(self):
     jira = self.jira_
     pivotal = self.pivotal_
     desiredSummary = "test_whenTicketNumberInCommentsOfOtherTickerTheRightSyncOccurs-1"
     desiredDescription = "overwritten!"
     newJiraItem = jiraItemFactory(Env().get("jira", "project"), "to be overwritten", "also overwritten" )
     self.syncNewItemToPivotal(newJiraItem, jira, pivotal)
     jiraItem = next(jira.items())
     
     newJiraItem = jiraItemFactory(Env().get("jira", "project"), "test_whenTicketNumberInCommentsOfOtherTickerTheRightSyncOccurs-2", "don't overwrite" )
     newJiraItem.addComment(TrackerItemComment(jiraItem.Id()))
     self.syncNewItemToPivotal(newJiraItem, jira, pivotal)
     
     for item in jira.items():
         jiraItem = item
     
     jiraItem.withDescription(desiredDescription)
     jiraItem.withSummary(desiredSummary)
     jira.update(jiraItem)
     
     syncItem = TrackerSyncBy.syncingItem()
     for item in jira.items():
         syncItem(item, toTracker=pivotal)
     
     
     for item in pivotal.items():
         updatedPivotalItem = item
     
     self.assertEqual(updatedPivotalItem.summary(), desiredSummary)
     self.assertEqual(updatedPivotalItem.description(), desiredDescription)
     pass 
 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_doNotAddItemWhenNoItemToAdd(self):
     toTracker = mock()
     fromTracker = mock()
     when(fromTracker).items(any()).thenReturn([])
     syncByAddingItems = TrackerSyncBy.addingItemsOfType(None)
     syncByAddingItems(fromTracker, toTracker)
     verify(toTracker, never).update()
 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
Пример #7
0
def syncUpdatedItemsInJira(toTracker, jira, jiraJql, afterDate,
                           obtainedFromFilter, andFilteringComments):
    syncChangesFor = TrackerSyncBy.syncingItem(obtainedFromFilter,
                                               andFilteringComments)
    for inJiraQuery in jiraJql:
        for ticket in jira.items(inJiraQuery + afterDate):
            syncChangesFor(ticket, toTracker)
 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_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()
def syncUpdatedItemsInPivotal(toTracker, pivotal, afterDate, obtainedFromFilter, andFilteringComments, jiraUrl):
    syncChangesFor = TrackerSyncBy.syncingItem(obtainedFromFilter, andFilteringComments)
    for pivotalStory in pivotal.items(afterDate):
        aJiraKey = pivotalStory.jiraKey()
        if aJiraKey is not None:
            pivotalStory.withJiraUrl(jiraUrl + aJiraKey)
            syncChangesFor(pivotalStory, toTracker)            
Пример #12
0
def addItemsFrom(jira, toTracker, jiraJql, jiraProject, filterInOnlyNewIssues,
                 ItemType, matchingAnIssue):
    syncByAddingItems = TrackerSyncBy.addingItemsOfType(
        ItemType, matchingAnIssue)
    for jiraQuery in jiraJql:
        jira.selectProject([jiraProject, jiraQuery + filterInOnlyNewIssues])
        syncByAddingItems(jira, toTracker)
    jira.selectProject([jiraProject, ""])
 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 updatePivotalAndSyncJiraItem_(jira, pivotal):
     item = next(pivotal.items())
     attributeSetter(item, PivotalUser(Env().get("pivotal", "username")))
     pivotal.update(item)
     item = next(pivotal.items())
     attributeSetter(item, PivotalUser(None))
     syncItem = TrackerSyncBy.syncingItem()
     syncItem(item, jira)
     return next(jira.items())
Пример #15
0
def syncUpdatedItemsInPivotal(toTracker, pivotal, afterDate,
                              obtainedFromFilter, andFilteringComments,
                              jiraUrl):
    syncChangesFor = TrackerSyncBy.syncingItem(obtainedFromFilter,
                                               andFilteringComments)
    for pivotalStory in pivotal.items(afterDate):
        aJiraKey = pivotalStory.jiraKey()
        if aJiraKey is not None:
            pivotalStory.withJiraUrl(jiraUrl + aJiraKey)
            syncChangesFor(pivotalStory, toTracker)
 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 updatePivotalAndSyncJiraItem_(jira, pivotal):
     item = next(pivotal.items())
     attributeSetter(item, PivotalUser(Env().get("pivotal",
                                                 "username")))
     pivotal.update(item)
     item = next(pivotal.items())
     attributeSetter(item, PivotalUser(None))
     syncItem = TrackerSyncBy.syncingItem()
     syncItem(item, jira)
     return next(jira.items())
 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_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_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 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_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_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()
 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_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)
 def test_canAddNewItemNotInTrackerAndwhenAddingUpdateItemBeforeUpdatingDetails(self):
     toTracker = mock()
     fromTracker = mock()
     itemToBeAdded = mock()
     detectedItem = mock()
     itemWithDetails = mock()
     TrackerItemType = mock()
     when(fromTracker).items(any()).thenReturn([detectedItem])
     when(toTracker).items(any()).thenReturn([])
     when(TrackerItemType).called().thenReturn(itemToBeAdded)
     when(toTracker).update(itemToBeAdded).thenReturn(itemWithDetails)
     syncByAddingItems = TrackerSyncBy.addingItemsOfType(TrackerItemType.called)
     syncByAddingItems(fromTracker, toTracker)
     inorder.verify(toTracker).items(any())
     inorder.verify(toTracker).update(itemToBeAdded)
     inorder.verify(toTracker).update(itemWithDetails)
 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_canAddNewItemNotInTrackerAndwhenAddingUpdateItemBeforeUpdatingDetails(
         self):
     toTracker = mock()
     fromTracker = mock()
     itemToBeAdded = mock()
     detectedItem = mock()
     itemWithDetails = mock()
     TrackerItemType = mock()
     when(fromTracker).items(any()).thenReturn([detectedItem])
     when(toTracker).items(any()).thenReturn([])
     when(TrackerItemType).called().thenReturn(itemToBeAdded)
     when(toTracker).update(itemToBeAdded).thenReturn(itemWithDetails)
     syncByAddingItems = TrackerSyncBy.addingItemsOfType(
         TrackerItemType.called)
     syncByAddingItems(fromTracker, toTracker)
     inorder.verify(toTracker).items(any())
     inorder.verify(toTracker).update(itemToBeAdded)
     inorder.verify(toTracker).update(itemWithDetails)
 def syncNewItemToPivotal(self, newJiraItem, jira, pivotal):
     jira.update(newJiraItem)
     syncByAddingItems = TrackerSyncBy.addingItemsOfType(PivotalTrackerItem)
     syncByAddingItems(fromTracker=jira, toTracker=pivotal)
def syncUpdatedItemsInJira(toTracker, jira, jiraJql, afterDate, obtainedFromFilter, andFilteringComments):
    syncChangesFor = TrackerSyncBy.syncingItem(obtainedFromFilter, andFilteringComments)
    for inJiraQuery in jiraJql:
        for ticket in jira.items(inJiraQuery + afterDate):
            syncChangesFor(ticket, toTracker)
def addItemsFrom(jira, toTracker, jiraJql, jiraProject, filterInOnlyNewIssues, ItemType, matchingAnIssue):
    syncByAddingItems = TrackerSyncBy.addingItemsOfType(ItemType, matchingAnIssue)
    for jiraQuery in jiraJql:
        jira.selectProject([jiraProject, jiraQuery + filterInOnlyNewIssues])
        syncByAddingItems(jira, toTracker)
    jira.selectProject([jiraProject, ""])
 def syncExistingItemFrom(self, fromTracker, toTracker):
     item = next(fromTracker.items())
     syncItem = TrackerSyncBy.syncingItem()
     syncItem(item, toTracker)
 def syncNewItemToPivotal(self, newJiraItem, jira, pivotal):
     jira.update(newJiraItem)
     syncByAddingItems = TrackerSyncBy.addingItemsOfType(PivotalTrackerItem)
     syncByAddingItems(fromTracker=jira, toTracker=pivotal)
 def syncExistingItemFrom(self, fromTracker, toTracker):
     item = next(fromTracker.items())
     syncItem = TrackerSyncBy.syncingItem()
     syncItem(item, toTracker)