def test_canDeleteAllItems(self): tracker = self.makeValidTracker() trackerInstance = self.trackerInstance_ item1 = Story() item1.story_id = 1234 item2 = Story() item2.story_id = 12345 when(trackerInstance).GetStories(any()).thenReturn([item1,item2]) when(trackerInstance).GetComments(any()).thenReturn([]) tracker.deleteAllItems() verify(trackerInstance).DeleteStory(item1.story_id) verify(trackerInstance).DeleteStory(item2.story_id) pass
def test_canDeleteAllItems(self): tracker = self.makeValidTracker() trackerInstance = self.trackerInstance_ item1 = Story() item1.story_id = 1234 item2 = Story() item2.story_id = 12345 when(trackerInstance).GetStories(any()).thenReturn([item1, item2]) when(trackerInstance).GetComments(any()).thenReturn([]) tracker.deleteAllItems() verify(trackerInstance).DeleteStory(item1.story_id) verify(trackerInstance).DeleteStory(item2.story_id) pass
def test_gettingItemAlsoGetsCommentsForItem(self): tracker = self.makeValidTracker() trackerInstance = self.trackerInstance_ story1 = Story() story1.story_id = 1234 story2 = Story() story2.story_id = 1235 when(trackerInstance).GetStories(any()).thenReturn([story1,story2]) when(trackerInstance).GetComments(any()).thenReturn([]) itemIterator = tracker.items() next(itemIterator) next(itemIterator) inorder.verify(trackerInstance).GetStories(any()) inorder.verify(trackerInstance).GetComments(story1.GetStoryId()) inorder.verify(trackerInstance).GetComments(story2.GetStoryId())
def test_gettingItemAlsoGetsCommentsForItem(self): tracker = self.makeValidTracker() trackerInstance = self.trackerInstance_ story1 = Story() story1.story_id = 1234 story2 = Story() story2.story_id = 1235 when(trackerInstance).GetStories(any()).thenReturn([story1, story2]) when(trackerInstance).GetComments(any()).thenReturn([]) itemIterator = tracker.items() next(itemIterator) next(itemIterator) inorder.verify(trackerInstance).GetStories(any()) inorder.verify(trackerInstance).GetComments(story1.GetStoryId()) inorder.verify(trackerInstance).GetComments(story2.GetStoryId())
def test_whenCommentAddedStoryIsAvailableToUpdate(self): story = Story() story.story_id = 1234 item = PivotalTrackerItem(story) comment = "blah" item.addComment(comment) storyToBeUpdated = item.decoratedStory() self.assertEqual(story.story_id, storyToBeUpdated.GetStoryId())
def itemWithComments(self, testing): issue = Story() issue.story_id = "1234" return testing.itemWithCommentsOfType(PivotalComment, PivotalTrackerItem, issue)
def test_canGetId(self): story = Story() story.story_id = 1234 item = PivotalTrackerItem(story) self.assertEqual(item.Id(), story.story_id) pass