def test_filterIsSentWhenSpecified(self):
     jira = JiraTracker()
     jiraInstance = self.getMockFor(jira)
     forFilter = "blah"
     self.setMocksForGettingItems(jiraInstance)
     self.assertRaises(StopIteration, next, jira._getItems(forFilter)) 
     verify(jiraInstance.service).getIssuesFromJqlSearch(any(),forFilter,any())
 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_updateAddsNewComments(self):
     jira = JiraTracker()
     jiraInstance = self.getMockFor(jira)
     testing = Testing()
     item = self.itemWithComments(testing)
     jira.update(item)
     verify(jiraInstance.service, times=2).addComment(any(), any(), any())
     pass
 def test_authSentWhenGettingBugs(self):
     jira = JiraTracker()
     jiraInstance = self.getMockFor(jira)
     self.setMocksForGettingItems(jiraInstance)
     itemIterator = jira._getItems()
     self.assertRaises(StopIteration, next, itemIterator)
     verify(jiraInstance.service).getIssuesFromJqlSearch(self.auth_, any(), any())
     pass
 def test_canntGetBugsForProject(self):
     jira = JiraTracker()
     jiraInstance = self.getMockFor(jira)
     jira.selectProject(["",""])
     fault = Holder()
     fault.faultstring = ""
     when(jiraInstance.service).getIssuesFromJqlSearch(any(), any(), any()).thenRaise(WebFault(fault, None))
     self.assertRaises(StopIteration, next, jira._getItems())
 def test_filterCombinedWithProjectJqlSentWhenSpecified(self):
     jira = JiraTracker()
     jiraInstance = self.getMockFor(jira)
     forFilter = "blah"
     jql = "1234" 
     jira.selectProject(["", jql])
     self.setMocksForGettingItems(jiraInstance)
     self.assertRaises(StopIteration, next, jira._getItems(forFilter)) 
     verify(jiraInstance.service).getIssuesFromJqlSearch(any(),jql + " and " + forFilter,any()) 
 def test_handleWhenNoCommentsAreReturned(self):
     jira = JiraTracker()
     jiraInstance = self.getMockFor(jira)
     ticket = mock()
     key = "12345"
     when(ticket).Id().thenReturn(key)
     when(jiraInstance.service).getComments(any(),any()).thenReturn(None)
     jira.addCommentsTo(ticket)
     verify(jiraInstance.service,times=0).addComment(any(), any(), any())
 def test_jiraItemsAreReturnedWithUrlPopulated(self):
     jira = JiraTracker()
     jiraInstance = self.getMockFor(jira)
     url = "http://www.jira.com/garbage/not/to/be/included/"
     jira.setLocationTo(url)
     item = RemoteIssue()
     item.key = "TEST-jt12345"
     when(jiraInstance.service).getIssuesFromJqlSearch(any(), any(), any()).thenReturn([item])
     when(jiraInstance.service).getComments(any(),any()).thenReturn([])
     self.assertEqual(next(jira.items()).jiraUrl(), "https://www.jira.com/browse/TEST-jt12345") 
 def test_canAddCommentsToTicket(self):
     jira = JiraTracker()
     jiraInstance = self.getMockFor(jira)
     testing = Testing()
     item = self.itemWithComments(testing)
     jira.updateCommentsFor(item)
     inorder.verify(jiraInstance.service).login(any(),any())
     inorder.verify(jiraInstance.service).addComment(self.auth_, testing.issue.key, {"body":testing.comment1.text()})
     inorder.verify(jiraInstance.service).addComment(self.auth_, testing.issue.key, {"body":testing.comment2.text()})
     pass
 def test_trackerCanAddItem(self):
     jira = JiraTracker()
     jiraInstance = self.getMockFor(jira)
     trackerItem = mock()
     values = {"one" : 1, "two":2}
     when(trackerItem).Id().thenReturn(None)
     when(trackerItem).asRemoteItem().thenReturn(values)
     when(trackerItem).comments('new').thenReturn([])
     jira.update(trackerItem)
     verify(jiraInstance.service).createIssue(self.auth_, values)
     pass    
 def test_canGetBugsForProject(self):
     jira = JiraTracker()
     jiraInstance = self.getMockFor(jira)
     project = ["test","JQL here"]
     jira.selectProject(project)
     when(jiraInstance.service).getIssuesFromJqlSearch(any(), project[1], any()).thenReturn([RemoteIssue(),RemoteIssue(),RemoteIssue()])
     itemIterator = jira._getItems() 
     next(itemIterator)
     next(itemIterator)
     next(itemIterator)
     self.assertRaises(StopIteration, next, itemIterator)
 def test_canGetAvailableStatusNextStepsForATicket(self):
     jira = JiraTracker()
     jiraInstance = self.getMockFor(jira)
     actions = ["next step1", "next step2"]
     item = mock()
     itemId = 1234 
     when(item).Id().thenReturn(itemId)
     when(jiraInstance.service).getAvailableActions(any(), any()).thenReturn(actions)
     actionsReturned = jira.getNextStatusActionsFor(item)
     verify(jiraInstance.service).getAvailableActions(self.auth_, itemId)
     self.assertEqual(actions, actionsReturned)
 def test_canUpdateExistingIssue(self):
     jira = JiraTracker()
     jiraInstance = self.getMockFor(jira)
     trackerItem = mock()
     values = [{'id':"fieldName" , 'values':"newValue"}, ]
     key = "12345"
     when(trackerItem).Id().thenReturn(key)
     when(trackerItem).piecesToUpdate().thenReturn(values)
     when(trackerItem).comments('new').thenReturn([])
     jira.update(trackerItem) 
     verify(jiraInstance.service).updateIssue(self.auth_, key, values)
     pass
 def test_canGetCommentsForTicket(self):
     jira = JiraTracker()
     jiraInstance = self.getMockFor(jira)
     ticket = mock()
     key = "12345"
     twoComments = [RemoteComment("comment0"), RemoteComment("comment1")]        
     when(ticket).Id().thenReturn(key)
     when(jiraInstance.service).getComments(any(),any()).thenReturn(twoComments)
     jira.addCommentsTo(ticket)
     verify(jiraInstance.service).getComments(self.auth_, key)
     inorder.verify(ticket).Id()
     inorder.verify(ticket).addComment(JiraComment(twoComments[0]), 'existing')
     inorder.verify(ticket).addComment(JiraComment(twoComments[1]), 'existing')
     pass
 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
 def test_noDeletionsWhenNoItems(self):
     jira = JiraTracker()
     jiraInstance = self.getMockFor(jira)
     jira.selectProject(["",""])
     self.setMocksForGettingItems(jiraInstance)
     jira.deleteAllItems()
     verify(jiraInstance.service, never).deleteIssue(any(), any())
     pass
Ejemplo n.º 17
0
def getTrackers():
    project = Env().get("pivotal", "project")
    pivotalTracker = PivotalTrackerFor(project)
    pivotalTracker.loginAs(Env().get("pivotal",
                                     "login")).withCredential(Env().get(
                                         "pivotal", "password"))
    jira = JiraTracker(Env().get("jira", "url"))
    jira.setTimezone(JiraTimezone(Env().get("jira", "timeToUtcHours")))
    jira.loginAs(Env().get("jira", "username")).withCredential(Env().get(
        "jira", "password"))
    PivotalToJiraStatusMap().insert(jira.getAvailableStatuses())
    return jira, pivotalTracker
def getTrackers():
    project = Env().get("pivotal", "project")
    pivotalTracker = PivotalTrackerFor(project)
    pivotalTracker.loginAs(Env().get("pivotal", "login")).withCredential(Env().get("pivotal", "password"))
    jira = JiraTracker(Env().get("jira", "url"))
    jira.setTimezone(JiraTimezone(Env().get("jira", "timeToUtcHours")))
    jira.loginAs(Env().get("jira","username")).withCredential(Env().get("jira","password"))
    PivotalToJiraStatusMap().insert(jira.getAvailableStatuses())
    return jira, pivotalTracker
 def test_trackerCanDeleteItem(self):
     jira = JiraTracker()
     jiraInstance = self.getMockFor(jira)
     jira.selectProject([])
     jiraTrackerItem = mock()
     itemId = 1234
     when(jiraTrackerItem).Id().thenReturn(itemId)
     jira.delete(jiraTrackerItem)
     verify(jiraInstance.service).deleteIssue(any(), itemId)
     pass
 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_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_canDeleteAllItems(self):
     jira = JiraTracker()
     jiraInstance = self.getMockFor(jira)
     jira.selectProject(["",""])
     item1 = RemoteIssue()
     item1.key = 1234
     item2 = RemoteIssue()
     item2.key = 12345
     when(jiraInstance.service).getIssuesFromJqlSearch(any(), any(), any()).thenReturn([item1,item2])
     when(jiraInstance.service).getComments(any(),any()).thenReturn([])
     jira.deleteAllItems()
     verify(jiraInstance.service).deleteIssue(any(), item1.key)
     verify(jiraInstance.service).deleteIssue(any(), item2.key)
     pass
 def __init__(self):
     tracker = JiraTracker(Env().get("jira", "url"))
     tracker.setTimezone(JiraTimezone(Env().get("jira", "timeToUtcHours")))
     tracker.loginAs(Env().get("jira","username")).withCredential(Env().get("jira","password"))
     tracker.selectProject([Env().get("jira","project"), Env().get("jira","jql")[0]])
     self.tracker_ = tracker
 def test_finalizeLogsout(self):
     jira = JiraTracker()
     jiraInstance = self.getMockFor(jira)
     jira.finalize()
     verify(jiraInstance.service).logout(any())
     pass
 def test_jiraUrlCanBeSet(self):
     jira = JiraTracker()
     url = "http://jira.com"
     jira.setLocationTo(url)
     self.assertEqual(jira.location(),url)
     pass
 def test_canConstructObject(self):
     jira  = JiraTracker()
     self.assertEqual(type(jira), JiraTracker)
     pass
 def test_canGetAvailableStatuses(self):
     jira = JiraTracker()
     jiraInstance = self.getMockFor(jira)
     jira.getAvailableStatuses()
     verify(jiraInstance.service).getStatuses(self.auth_)
 def test_canGetTimeZoneInfoForThisJira(self):
     jira = JiraTracker()
     jiraInstance = self.getMockFor(jira)
     timezone = mock()
     jira.setTimezone(timezone)
     self.assertEqual(timezone, jira.timezone())