def test_canSetSummary(self): testTicket = testRemoteIssueFactory() ticket = JiraTicket(testTicket) summary = "New" ticket.setSummary(summary) self.assertEqual(ticket.summary(), summary) pass
def test_canSetSummary(self): testTicket = testRemoteIssueFactory() ticket = JiraTicket(testTicket) summary = "New" ticket.setSummary(summary) self.assertEqual(ticket.summary(),summary) pass
def test_canGetStatusWhenAddedViaUnderlying(self): PivotalToJiraStatusMap().addMapping(jira="Closed", pivotal="Accepted") jiraStatus = JiraStatus(6, "Closed") PivotalToJiraStatusMap().insert(jiraStatus) testTicket = JiraTicket() testTicket.setStatus(jiraStatus.id) item = JiraTrackerItem(testTicket) self.assertEqual(item.status().jira(), [jiraStatus.name]) PivotalToJiraStatusMap().reset()
def test_canGetRemoteItemDictionary(self): testTicket = testRemoteIssueFactory() ticket = JiraTicket(testTicket) remoteItemDictionary = testTicket.__dict__ remoteItemDictionary["affectsVersions"][0] = remoteItemDictionary["affectsVersions"][0].__dict__ remoteItemDictionary["components"][0] = remoteItemDictionary["components"][0].__dict__ remoteItemDictionary["customFieldValues"][0] = remoteItemDictionary["customFieldValues"][0].__dict__ remoteItemDictionary["fixVersions"][0] = remoteItemDictionary["fixVersions"][0].__dict__ self.assertEqual(ticket.asDictionary(),remoteItemDictionary) pass
def test_canSeedWithTicket(self): testTicket = JiraTicket() summary = "Test Summary" testTicket.setSummary(summary) item = JiraTrackerItem(testTicket) self.assertEqual(item.summary(), summary) testIssue = RemoteIssue() description = "Test Description" testIssue.description = description item = JiraTrackerItem(testIssue) self.assertEqual(item.description(), description)
def test_whenSeedingWithRemoteStatusForJira(self): ticket = JiraTicket() statusId = "1234" closed = "Closed" ticket.setStatus(statusId) mapObject = mock() when(mapObject).translateStatusTo('jiraStatusName', statusId).thenReturn([closed]) status = TrackerItemStatus(ticket, apiObject=mapObject) status.pivotal() inorder.verify(mapObject).translateStatusTo('jiraStatusName', statusId) inorder.verify(mapObject).translateStatusTo('pivotal', closed) self.assertEqual(status.jira(), [closed])
def test_canAddStatus(self): PivotalToJiraStatusMap().addMapping(jira="Closed", pivotal="Accepted") jiraStatus = JiraStatus(6, "Closed") PivotalToJiraStatusMap().insert(jiraStatus) item = JiraTrackerItem() statusId = 6 ticket = JiraTicket() ticket.setStatus(statusId) status = TrackerItemStatus(ticket) item.withStatus(status) self.assertEqual(item.status(), status) self.assertEqual(item.piecesToUpdate(), [{'id':"status", 'values':['',]},]) PivotalToJiraStatusMap().reset()
def test_canGetRemoteItemDictionary(self): testTicket = testRemoteIssueFactory() ticket = JiraTicket(testTicket) remoteItemDictionary = testTicket.__dict__ remoteItemDictionary["affectsVersions"][0] = remoteItemDictionary[ "affectsVersions"][0].__dict__ remoteItemDictionary["components"][0] = remoteItemDictionary[ "components"][0].__dict__ remoteItemDictionary["customFieldValues"][0] = remoteItemDictionary[ "customFieldValues"][0].__dict__ remoteItemDictionary["fixVersions"][0] = remoteItemDictionary[ "fixVersions"][0].__dict__ self.assertEqual(ticket.asDictionary(), remoteItemDictionary) pass
def test_canGetUpdatedAtDateTime(self): testTicket = JiraTicket() date = datetime.now() testTicket.details_.updated = date timezone = UTC() item = JiraTrackerItem(testTicket, timezone) self.assertEqual(date, item.updatedAt()) self.assertEqual(None, item.updatedAt().tzinfo)
def test_canAddStatus(self): PivotalToJiraStatusMap().addMapping(jira="Closed", pivotal="Accepted") jiraStatus = JiraStatus(6, "Closed") PivotalToJiraStatusMap().insert(jiraStatus) item = JiraTrackerItem() statusId = 6 ticket = JiraTicket() ticket.setStatus(statusId) status = TrackerItemStatus(ticket) item.withStatus(status) self.assertEqual(item.status(), status) self.assertEqual(item.piecesToUpdate(), [ { 'id': "status", 'values': [ '', ] }, ]) PivotalToJiraStatusMap().reset()
def test_canGetName(self): testTicket = testRemoteIssueFactory() ticket = JiraTicket(testTicket) self.assertEqual(ticket.summary(), testTicket.summary) pass
def test_canUpdateAssignee(self): testTicket = testRemoteIssueFactory() ticket = JiraTicket(testTicket) assignee = "me" ticket.setAssignee(assignee) self.assertEqual(assignee, ticket.assignee())
def test_canGetAssignee(self): testTicket = testRemoteIssueFactory() ticket = JiraTicket(testTicket) self.assertEqual(testTicket.assignee, ticket.assignee())
def test_canUpdateReporter(self): testTicket = testRemoteIssueFactory() ticket = JiraTicket(testTicket) reporter = "me" ticket.setReporter(reporter) self.assertEqual(reporter, ticket.reporter())
def test_canSetStatus(self): testTicket = testRemoteIssueFactory() ticket = JiraTicket(testTicket) statusId = 6 ticket.setStatus(statusId) self.assertEqual(ticket.status(), statusId)
def _addTicket(self, ticket): if isinstance(ticket, JiraTicket): self.ticket_ = ticket return self.ticket_ = JiraTicket(ticket)
class JiraTrackerItem(TrackerItem): ''' classdocs ''' def __init__(self, ticket=None, timezone=None): ''' Constructor ''' super(JiraTrackerItem, self).__init__() self.piecesToUpdate_ = [] self._addTicket(defaultParameter(JiraTicket, ticket)) self.withDescription(self.ticket_.description()) self.withSummary(self.ticket_.summary()) self.withStatus(TrackerItemStatus(self.ticket_)) self.withType("bug") self.withRequestor(JiraUser(self.ticket_.reporter())) self.withOwner(JiraUser(self.ticket_.assignee())) self.timezone_ = timezone self.piecesToUpdate_ = [] def _addTicket(self, ticket): if isinstance(ticket, JiraTicket): self.ticket_ = ticket return self.ticket_ = JiraTicket(ticket) def underlying(self): return self.ticket_ def withSummary(self, summary): if self.summary() == summary: return super(JiraTrackerItem, self).withSummary(summary) self.ticket_.setSummary(summary) self.piecesToUpdate_.append({'id':"summary", 'values':[summary,]}) return self def withDescription(self, description): if self.description() == description: return super(JiraTrackerItem, self).withDescription(description) self.ticket_.setDescrition(description) self.piecesToUpdate_.append({'id':"description", 'values':[description,]}) return self def asRemoteItem(self): return self.underlying().asDictionary() def Id(self): return self.underlying().Id() def piecesToUpdate(self): return self.piecesToUpdate_ def withJiraUrl(self, updateUrl): self.url_ = updateUrl def jiraUrl(self): return self.url_ def jiraKey(self): return self.Id() def withJiraKey(self, jiraKey): return def copyTypeSpecificDataTo(self, item): super(JiraTrackerItem, self).copyTypeSpecificDataTo(item) item.withJiraKey(self.jiraKey()) item.withJiraUrl(self.jiraUrl()) def canBeSyncedWith(self, toSyncWith): if toSyncWith is None: return False return toSyncWith.jiraKey() == self.jiraKey() def withStatus(self, status): if status == self.status(): return super(JiraTrackerItem, self).withStatus(status) self.piecesToUpdate_.append({'id':"status", 'values':[self.ticket_.status(),]}) return self def updatedAt(self): dateAndTime = deepcopy(self.underlying().updatedAt()).replace(tzinfo=self.timezone_) return self._convertToUtc(dateAndTime) def withRequestor(self, requestor): if self.requestor() == requestor: return if self.requestor() is not None and self.requestor().unknown(): return if self.requestor() is not None and requestor.jira() is None: return super(JiraTrackerItem, self).withRequestor(requestor) self.ticket_.setReporter(requestor.jira()) self.piecesToUpdate_.append({'id':"reporter", 'values':[requestor.jira(),]}) return self def withOwner(self, owner): if self.owner() == owner: return if self.owner() is not None and self.owner().unknown(): return if self.owner() is not None and owner.jira() is None: return super(JiraTrackerItem, self).withOwner(owner) self.ticket_.setAssignee(owner.jira()) self.piecesToUpdate_.append({'id':"assignee", 'values':[owner.jira(),]}) return self
def test_canGetName(self): testTicket = testRemoteIssueFactory() ticket = JiraTicket(testTicket) self.assertEqual(ticket.summary(),testTicket.summary) pass
def test_canGetUpdatedDate(self): testTicket = testRemoteIssueFactory() ticket = JiraTicket(testTicket) self.assertEqual(ticket.updatedAt(), testTicket.updated)
def test_canGetReporter(self): testTicket = testRemoteIssueFactory() ticket = JiraTicket(testTicket) self.assertEqual(testTicket.reporter, ticket.reporter())
def test_canGetRemoteItemId(self): testTicket = testRemoteIssueFactory() ticket = JiraTicket(testTicket) self.assertEqual(ticket.Id(), testTicket.key) pass