def test_whenSeedingWithUserForPivotal(self):
     pivotalUser = "******"
     jiraUser = "******"
     mapObject = mock()
     when(mapObject).translateUserTo('jira', pivotalUser).thenReturn(jiraUser)
     userObject = PivotalUser(pivotalUser, apiObject=mapObject)
     self.assertEqual(pivotalUser, userObject.pivotal())
     self.assertEqual(jiraUser, userObject.jira())
 def test_whenSeedingWithUserForPivotal(self):
     pivotalUser = "******"
     jiraUser = "******"
     mapObject = mock()
     when(mapObject).translateUserTo('jira',
                                     pivotalUser).thenReturn(jiraUser)
     userObject = PivotalUser(pivotalUser, apiObject=mapObject)
     self.assertEqual(pivotalUser, userObject.pivotal())
     self.assertEqual(jiraUser, userObject.jira())
 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())
示例#4
0
 def __init__(self, story=None, timezone=None):
     '''
     Constructor
     '''
     super(PivotalTrackerItem, self).__init__()
     self.piecesToUpdate_ = []
     self.story_ = defaultParameter(Story, story)
     self._normalizeSummary(self.story_.GetName())
     self._normalizeDescription(self.story_.GetDescription())
     self.withStatus(TrackerItemStatus(self.story_.GetCurrentState()))
     self.withType(self.story_.GetStoryType())
     self.withRequestor(PivotalUser(self.story_.GetRequestedBy()))
     self.withOwner(PivotalUser(self.story_.GetOwnedBy()))
     self.timezone_ = timezone
     self._determineIfNeedToUpdate(story)
示例#5
0
 def test_cannotSetOwnerForStory(self):
     story = Story()
     owner = "me"
     story.SetOwnedBy(owner)
     item = PivotalTrackerItem(story)
     item.withOwner(PivotalUser(owner))
     self.assertEqual([], item.decoratedStory().UPDATE_FIELDS)
示例#6
0
 def test_canSetOwner(self):
     item = PivotalTrackerItem()
     owner = "me"
     item.withOwner(PivotalUser(owner))
     self.assertEqual(owner, item.owner().pivotal())
     self.assertEqual(owner, item.underlying().GetOwnedBy())
     self.assertTrue('owned_by' in item.decoratedStory().UPDATE_FIELDS)
示例#7
0
 def test_cannotSetRequestorForStory(self):
     story = Story()
     requestor = "me"
     story.SetRequestedBy(requestor)
     item = PivotalTrackerItem(story)
     item.withRequestor(PivotalUser(requestor))
     self.assertEqual([], item.decoratedStory().UPDATE_FIELDS)
示例#8
0
 def test_canSetRequestor(self):
     item = PivotalTrackerItem()
     requestor = "me"
     item.withRequestor(PivotalUser(requestor))
     self.assertEqual(requestor, item.requestor().pivotal())
     self.assertEqual(requestor, item.underlying().GetRequestedBy())
     self.assertTrue('requested_by' in item.decoratedStory().UPDATE_FIELDS)
 def test_inequalityOfStatused(self):
     pivotalUser = "******"
     jiraUser = "******"
     mapObject = mock()
     when(mapObject).translateUserTo('pivotal',
                                     jiraUser).thenReturn("garbage")
     when(mapObject).translateUserTo('jira',
                                     pivotalUser).thenReturn("garbage")
     status = PivotalUser(pivotalUser, apiObject=mapObject)
     statusEqual = JiraUser(jiraUser, apiObject=mapObject)
     self.assertTrue(status != statusEqual)
     self.assertTrue(status != "garbage")
 def test_equalityOfStatuses(self):
     pivotalUser = "******"
     jiraUser = "******"
     mapObject = mock()
     when(mapObject).translateUserTo('pivotal',
                                     jiraUser).thenReturn(pivotalUser)
     when(mapObject).translateUserTo('jira',
                                     pivotalUser).thenReturn(jiraUser)
     status = PivotalUser(pivotalUser, apiObject=mapObject)
     statusEqual = JiraUser(jiraUser, apiObject=mapObject)
     self.assertTrue(status == statusEqual)
     self.assertFalse(status is statusEqual)
     self.assertTrue(status == status)
 def test_canChangeOwner(self):
     tracker = self.pivotal_
     item = PivotalTrackerItem().withSummary(
         "test_canChangeOwner-1").withDescription(
             "can change the owner of this ticket?").withType("bug")
     Testing.putItemToTrackerAndChangeStatusTo("started", item, tracker)
     item = next(tracker.items())
     newOwner = PivotalUser(Env().get("pivotal", "otherUser"))
     item.withOwner(newOwner)
     tracker.update(item)
     item = next(tracker.items())
     self.assertTrue(
         Env().get("pivotal", "otherUser") in item.owner().pivotal())
 def test_canChangeRequestor(self):
     tracker = self.pivotal_
     item = PivotalTrackerItem().withSummary(
         "test_canChangeRequestor-1").withDescription(
             "can change the requestor of this ticket?")
     tracker.update(item)
     item = next(tracker.items())
     newRequestor = PivotalUser(Env().get("pivotal", "otherUser"))
     item.withRequestor(newRequestor)
     tracker.update(item)
     item = next(tracker.items())
     self.assertTrue(
         Env().get("pivotal", "otherUser") in item.requestor().pivotal())
 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_isUnknownWhenOneIsNone(self):
     user = JiraUser("blah")
     self.assertTrue(user.unknown())
     user = PivotalUser("blah")
     self.assertTrue(user.unknown())