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_canFilterTicketsReturnedFromJiraOnlyOneMatchIsFound(self): tracker = self.jira_ item = jiraItemFactory(Env().get("jira", "project"), "test_canFilterTicketsReturnedFromJiraOnlyOneMatchIsFound", "description") tracker.update(item) searchableSummary = "searchForMe" forFilter = "summary ~ " + searchableSummary item = jiraItemFactory(Env().get("jira", "project"), searchableSummary, "description") tracker.update(item) item = tracker.items(forFilter) self.assertEqual(next(item).summary(), searchableSummary) self.assertRaises(StopIteration, next, item)
def test_canFilterTicketsReturnedFromJiraOnlyOneMatchIsFound(self): tracker = self.jira_ item = jiraItemFactory( Env().get("jira", "project"), "test_canFilterTicketsReturnedFromJiraOnlyOneMatchIsFound", "description") tracker.update(item) searchableSummary = "searchForMe" forFilter = "summary ~ " + searchableSummary item = jiraItemFactory(Env().get("jira", "project"), searchableSummary, "description") tracker.update(item) item = tracker.items(forFilter) self.assertEqual(next(item).summary(), searchableSummary) self.assertRaises(StopIteration, next, item)
def test_canAddCommentsToTicket(self): tracker = self.jira_ item = jiraItemFactory(Env().get("jira", "project"), "test_canAddCommentsToTicket-1", "can comment on this?") tracker.update(item) aComment = Testing.addCommentToItemIn(tracker) item = next(tracker.items()) self.assertEqual(item.comments()[0], aComment)
def test_canAdjustStateOfTicket(self): tracker = self.jira_ Testing.mapStatuses(tracker) item = jiraItemFactory(Env().get("jira", "project"), "test_canAdjustStateOfTicket-1", "can change the status of this ticket?") Testing.putItemToTrackerAndChangeStatusTo("accepted", item, tracker) item = next(tracker.items()) self.assertEqual(item.status(), TrackerItemStatus("accepted"))
def test_canMoveNewStateToInWork(self): tracker = self.jira_ Testing.mapStatuses(tracker) item = jiraItemFactory(Env().get("jira", "project"), "test_canMoveNewStateToInWork-1", "can change the status to In Work?") Testing.putItemToTrackerAndChangeStatusTo("started", item, tracker) item = next(tracker.items()) self.assertEqual(item.status(), TrackerItemStatus("started"))
def test_canGetAssignee(self): tracker = self.jira_ item = jiraItemFactory(Env().get("jira", "project"), "test_canGetAssignee-1", "can get assignee") tracker.update(item) item = next(tracker.items()) self.assertEqual(Env().get("jira", "username"), item.owner().jira())
def test_canUpdateItemAlreadyInJira(self): tracker = self.jira_ item = jiraItemFactory(Env().get("jira", "project"), "test_canUpdateItemAlreadyInJira-1", "can update this?") tracker.update(item) Testing.canUpdateItemsIn(tracker, self)
def test_doNotOverwriteJiraOwnerWhenUnknown(self): jira = self.jira_ pivotal = self.pivotal_ newJiraItem = jiraItemFactory(Env().get("jira", "project"), "test_doNotOverwriteJiraOwnerWhenUnknown", "a test description") getOtherUserAfterUpdatingJiraItem = self.create_getOtherUserAfterUpdatingJiraItem(JiraTrackerItem.withOwner) user = getOtherUserAfterUpdatingJiraItem(jira, pivotal, newJiraItem) jiraItem = self.tryToSyncUnknownUser(jira, pivotal) self.assertEqual(jiraItem.owner(), user)
def test_canRemoveAllStoriesFromJira(self): tracker = self.jira_ item = jiraItemFactory(Env().get("jira", "project"), "test_canRemoveAllStoriesFromJira-1", "can delete this?") tracker.update(item) item.withSummary("test_canRemoveAllStoriesFromJira-2") tracker.update(item) tracker.deleteAllItems() self.assertRaises(StopIteration, next, tracker.items())
def test_canGetReporter(self): tracker = self.jira_ item = jiraItemFactory(Env().get("jira", "project"), "test_canGetReporter-1", "can get reporter") tracker.update(item) item = next(tracker.items()) self.assertEqual(Env().get("jira", "username"), item.requestor().jira())
def test_issueInJiraAndInPivotalAreSyncable(self): jira = self.jira_ pivotal = self.pivotal_ newJiraItem = jiraItemFactory(Env().get("jira", "project"), "test_issueInJiraAndInPivotalAreSyncable", "a test description") self.syncNewItemToPivotal(newJiraItem, jira, pivotal) jiraItem = next(jira.items()) pivotalItem = next(pivotal.items()) self.assertTrue(pivotalItem.canBeSyncedWith(jiraItem))
def test_canAddStoryStoryToJira(self): tracker = self.jira_ name = "test_canAddStoryStoryToPivotal" description = "this is a test" item = jiraItemFactory(Env().get("jira", "project"), name, description) tracker.update(item) story = next(tracker.items()) self.assertEqual(story.summary(), name) self.assertEqual(story.description(), description)
def test_ticketUpdatedWhenNotChangedDoesNotModifyTicket(self): tracker = self.jira_ item = jiraItemFactory(Env().get("jira", "project"), "test_ticketUpdatedWhenNotChangedDoesNotModifyTicket", "description") tracker.update(item) itemInJira = next(tracker.items()) itemInJira.syncWith(itemInJira) tracker.update(itemInJira) updatedItem = next(tracker.items()) self.assertEquals(itemInJira.updatedAt(), updatedItem.updatedAt())
def test_20000PlusCharacterCommentsAreNotSyned(self): jira = self.jira_ pivotal = self.pivotal_ newJiraItem = jiraItemFactory(Env().get("jira", "project"), "test_20000PlusCharacterCommentsAreNotSyned", "blah") commentOnJira = TrackerItemComment(Testing.stringOfAsOfSize(20002)) newJiraItem.addComment(commentOnJira) self.syncNewItemToPivotal(newJiraItem, jira, pivotal) pivotalItem = next(pivotal.items()) self.assertEqual(len(pivotalItem.comments()), 0)
def test_canFilterTicketsReturnedFromJiraSoNoMatchesAreFound(self): tracker = self.jira_ item = jiraItemFactory( Env().get("jira", "project"), "test_canFilterTicketsReturnedFromJiraSoNoMatchesAreFound", "description") tracker.update(item) forFilter = "labels = WLK" self.assertRaises(StopIteration, next, tracker.items(forFilter))
def test_newIssueInJiraIsCopiedToPivotal(self): jira = self.jira_ pivotal = self.pivotal_ summary = "test_newIssueInJiraIsCopiedToPivotal" newJiraItem = jiraItemFactory(Env().get("jira", "project"), summary, "a test description") self.syncNewItemToPivotal(newJiraItem, jira, pivotal) pivotalItem = next(pivotal.items()) self.assertEqual(pivotalItem.summary(), summary) self.assertEqual(pivotalItem.type(), 'bug')
def test_canSyncOwnerToPivotalForExistingItems(self): jira = self.jira_ pivotal = self.pivotal_ newJiraItem = jiraItemFactory(Env().get("jira", "project"), "test_canSyncOwnerToPivotalForExistingItems", "a test description") getOtherUserAfterUpdatingJiraItem = self.create_getOtherUserAfterUpdatingJiraItem(JiraTrackerItem.withOwner) user = getOtherUserAfterUpdatingJiraItem(jira, pivotal, newJiraItem) self.syncExistingItemFrom(jira, toTracker=pivotal) pivotalItem = next(pivotal.items()) self.assertEqual(pivotalItem.owner(),user)
def test_doNotOverwriteJiraOwnerWhenUnassignedInPivotal(self): jira = self.jira_ pivotal = self.pivotal_ newJiraItem = jiraItemFactory(Env().get("jira", "project"), "test_doNotOverwriteJiraOwnerWhenUnassignedInPivotal", "a test description") newJiraItem.withOwner(PivotalUser(Env().get("pivotal", "otherUser"))) getOtherUserAfterUpdatingJiraItem = self.create_getOtherUserAfterUpdatingJiraItem(JiraTrackerItem.withRequestor) user = getOtherUserAfterUpdatingJiraItem(jira, pivotal, newJiraItem) updatePivotalAndSyncJiraItem = self.create_updatePivotalAndSyncJiraItem(PivotalTrackerItem.withOwner) jiraItem = updatePivotalAndSyncJiraItem(jira, pivotal) self.assertEqual(jiraItem.owner(), user)
def test_canDownloadStoriesFromJira(self): tracker = self.jira_ item = jiraItemFactory(Env().get("jira", "project"), "test_canDownloadStoriesFromJira-1", "A test description") tracker.update(item) item.withSummary("test_canDownloadStoriesFromJira-2") tracker.update(item) storiesIterator = tracker.items() next(storiesIterator) next(storiesIterator) self.assertRaises(StopIteration, next, storiesIterator)
def test_issueInJiraAndInPivotalAreSyncable(self): jira = self.jira_ pivotal = self.pivotal_ newJiraItem = jiraItemFactory( Env().get("jira", "project"), "test_issueInJiraAndInPivotalAreSyncable", "a test description") self.syncNewItemToPivotal(newJiraItem, jira, pivotal) jiraItem = next(jira.items()) pivotalItem = next(pivotal.items()) self.assertTrue(pivotalItem.canBeSyncedWith(jiraItem))
def test_20000PlusCharacterCommentsAreNotSyned(self): jira = self.jira_ pivotal = self.pivotal_ newJiraItem = jiraItemFactory( Env().get("jira", "project"), "test_20000PlusCharacterCommentsAreNotSyned", "blah") commentOnJira = TrackerItemComment(Testing.stringOfAsOfSize(20002)) newJiraItem.addComment(commentOnJira) self.syncNewItemToPivotal(newJiraItem, jira, pivotal) pivotalItem = next(pivotal.items()) self.assertEqual(len(pivotalItem.comments()), 0)
def test_doNotOverwriteJiraOwnerWhenUnknown(self): jira = self.jira_ pivotal = self.pivotal_ newJiraItem = jiraItemFactory( Env().get("jira", "project"), "test_doNotOverwriteJiraOwnerWhenUnknown", "a test description") getOtherUserAfterUpdatingJiraItem = self.create_getOtherUserAfterUpdatingJiraItem( JiraTrackerItem.withOwner) user = getOtherUserAfterUpdatingJiraItem(jira, pivotal, newJiraItem) jiraItem = self.tryToSyncUnknownUser(jira, pivotal) self.assertEqual(jiraItem.owner(), user)
def test_canSyncOwnerToPivotalForExistingItems(self): jira = self.jira_ pivotal = self.pivotal_ newJiraItem = jiraItemFactory( Env().get("jira", "project"), "test_canSyncOwnerToPivotalForExistingItems", "a test description") getOtherUserAfterUpdatingJiraItem = self.create_getOtherUserAfterUpdatingJiraItem( JiraTrackerItem.withOwner) user = getOtherUserAfterUpdatingJiraItem(jira, pivotal, newJiraItem) self.syncExistingItemFrom(jira, toTracker=pivotal) pivotalItem = next(pivotal.items()) self.assertEqual(pivotalItem.owner(), user)
def test_ticketUpdatedWhenNotChangedDoesNotModifyTicket(self): tracker = self.jira_ item = jiraItemFactory( Env().get("jira", "project"), "test_ticketUpdatedWhenNotChangedDoesNotModifyTicket", "description") tracker.update(item) itemInJira = next(tracker.items()) itemInJira.syncWith(itemInJira) tracker.update(itemInJira) updatedItem = next(tracker.items()) self.assertEquals(itemInJira.updatedAt(), updatedItem.updatedAt())
def test_canSyncStatusToPivotalForExistingItems(self): jira = self.jira_ pivotal = self.pivotal_ newJiraItem = jiraItemFactory(Env().get("jira", "project"), "test_canSyncStatusToPivotalForExistingItems", "a test description") self.syncNewItemToPivotal(newJiraItem, jira, pivotal) jiraItem = next(jira.items()) status = TrackerItemStatus("accepted") jiraItem.withStatus(status) jira.update(jiraItem) self.syncExistingItemFrom(jira, pivotal) pivotalItem = next(pivotal.items()) self.assertEqual(pivotalItem.status(),status)
def test_canSetAssignee(self): Testing.mapUsers() tracker = self.jira_ item = jiraItemFactory(Env().get("jira", "project"), "test_canSetAssignee-1", "can set assignee") tracker.update(item) item = next(tracker.items()) user = JiraUser(Env().get("jira", "otherUser")) item.withOwner(user) tracker.update(item) item = next(tracker.items()) self.assertEqual(Env().get("jira", "otherUser"), item.owner().jira()) PivotalToJiraUserMap().reset()
def test_commentOnIssueInPivotalIsSyncedToJira(self): jira = self.jira_ pivotal = self.pivotal_ newJiraItem = jiraItemFactory(Env().get("jira", "project"), "test_commentOnIssueInPivotalIsSyncedToJira", "blah") self.syncNewItemToPivotal(newJiraItem, jira, pivotal) commentOnPivotal = TrackerItemComment("this commentOnPivotal can be synced") pivotalItem = next(pivotal.items()) pivotalItem.addComment(commentOnPivotal) pivotal.update(pivotalItem) self.syncExistingItemFrom(pivotal, jira) updatedJiraItem = next(jira.items()) self.assertEqual(updatedJiraItem.comments()[0], commentOnPivotal) pass
def test_commentOnIssueInJiraIsSyncedToPivotal(self): jira = self.jira_ pivotal = self.pivotal_ newJiraItem = jiraItemFactory(Env().get("jira", "project"), "to test comments", "blah") self.syncNewItemToPivotal(newJiraItem, jira, pivotal) commentOnJira = TrackerItemComment("this commentOnJira can be synced") jiraItem = next(jira.items()) jiraItem.addComment(commentOnJira) jira.update(jiraItem) self.syncExistingItemFrom(jira, pivotal) updatedPivotalItem = next(pivotal.items()) self.assertEqual(updatedPivotalItem.comments()[0], commentOnJira) pass
def test_canSyncStatusToPivotalForExistingItems(self): jira = self.jira_ pivotal = self.pivotal_ newJiraItem = jiraItemFactory( Env().get("jira", "project"), "test_canSyncStatusToPivotalForExistingItems", "a test description") self.syncNewItemToPivotal(newJiraItem, jira, pivotal) jiraItem = next(jira.items()) status = TrackerItemStatus("accepted") jiraItem.withStatus(status) jira.update(jiraItem) self.syncExistingItemFrom(jira, pivotal) pivotalItem = next(pivotal.items()) self.assertEqual(pivotalItem.status(), status)
def test_doNotOverwriteJiraOwnerWhenUnassignedInPivotal(self): jira = self.jira_ pivotal = self.pivotal_ newJiraItem = jiraItemFactory( Env().get("jira", "project"), "test_doNotOverwriteJiraOwnerWhenUnassignedInPivotal", "a test description") newJiraItem.withOwner(PivotalUser(Env().get("pivotal", "otherUser"))) getOtherUserAfterUpdatingJiraItem = self.create_getOtherUserAfterUpdatingJiraItem( JiraTrackerItem.withRequestor) user = getOtherUserAfterUpdatingJiraItem(jira, pivotal, newJiraItem) updatePivotalAndSyncJiraItem = self.create_updatePivotalAndSyncJiraItem( PivotalTrackerItem.withOwner) jiraItem = updatePivotalAndSyncJiraItem(jira, pivotal) self.assertEqual(jiraItem.owner(), user)
def test_existingIssueInJiraIsSyncedWithExistingIssueInPivotal(self): jira = self.jira_ pivotal = self.pivotal_ desiredSummary = "test_existingIssueInJiraIsSyncedWithExistingIssueInPivotal" desiredDescription = "overwritten!" newJiraItem = jiraItemFactory(Env().get("jira", "project"), "to be overwritten", "also overwritten" ) self.syncNewItemToPivotal(newJiraItem, jira, pivotal) jiraItem = next(jira.items()) jiraItem.withDescription(desiredDescription) jiraItem.withSummary(desiredSummary) jira.update(jiraItem) self.syncExistingItemFrom(jira, pivotal) updatedPivotalItem = next(pivotal.items()) self.assertEqual(updatedPivotalItem.summary(), desiredSummary) self.assertEqual(updatedPivotalItem.description(), desiredDescription) pass
def test_existingIssueInJiraIsSyncedWithExistingIssueInPivotal(self): jira = self.jira_ pivotal = self.pivotal_ desiredSummary = "test_existingIssueInJiraIsSyncedWithExistingIssueInPivotal" desiredDescription = "overwritten!" newJiraItem = jiraItemFactory(Env().get("jira", "project"), "to be overwritten", "also overwritten") self.syncNewItemToPivotal(newJiraItem, jira, pivotal) jiraItem = next(jira.items()) jiraItem.withDescription(desiredDescription) jiraItem.withSummary(desiredSummary) jira.update(jiraItem) self.syncExistingItemFrom(jira, pivotal) updatedPivotalItem = next(pivotal.items()) self.assertEqual(updatedPivotalItem.summary(), desiredSummary) self.assertEqual(updatedPivotalItem.description(), desiredDescription) pass
def test_canFilterTicketsReturnedFromJiraSoNoMatchesAreFound(self): tracker = self.jira_ item = jiraItemFactory(Env().get("jira", "project"), "test_canFilterTicketsReturnedFromJiraSoNoMatchesAreFound", "description") tracker.update(item) forFilter = "labels = WLK" self.assertRaises(StopIteration, next, tracker.items(forFilter))
def test_canDeleteJiraIssue(self): tracker = self.jira_ item = jiraItemFactory(Env().get("jira", "project"), "test_canDeleteJiraIssue", "A test description") tracker.update(item) tracker.delete(next(tracker.items()))