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 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 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_onlyTakeCommentsFromIssueForByFilter(self):
     toTracker = mock()
     aTestItemFilter = mock()
     syncCommentsFor = TrackerSyncBy.syncingItem(aTestItemFilter.calledWith)
     when(toTracker).items(None).thenRaise(StopIteration)
     syncCommentsFor(None, toTracker)
     verify(aTestItemFilter).calledWith(None)
Esempio n. 6
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_doNotAddCommentsWhenItemNotFound(self):
     toTracker = mock()
     item = mock()
     syncCommentsFor = TrackerSyncBy.syncingItem()
     when(toTracker).items(None).thenRaise(StopIteration)
     syncCommentsFor(item, toTracker)
     verify(toTracker, never).update(item) 
 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())
 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)
Esempio n. 14
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 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_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 syncExistingItemFrom(self, fromTracker, toTracker):
     item = next(fromTracker.items())
     syncItem = TrackerSyncBy.syncingItem()
     syncItem(item, toTracker)
 def syncExistingItemFrom(self, fromTracker, toTracker):
     item = next(fromTracker.items())
     syncItem = TrackerSyncBy.syncingItem()
     syncItem(item, toTracker)
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)