def testCommand(self): """should return the correct data for the story""" # mock user arguments mock_helper = MockHelper() mock_helper.story_id = 'pro-xx' data = Story() data.sprint_name = 'my sprint name' # mock the jira manager and its return values jira_manager = mock_helper.get_jira_manager() jira_manager.get_story = MagicMock(return_value=data) command = RetrieveJiraInformationForConfigCommand() command.get_jira_manager = MagicMock(return_value=jira_manager) output_mock = Mock() command._output = output_mock command.run(mock_helper) self.assertEquals((data, 'my+sprint+name'), output_mock.call_args[0])
def parse_stories( self, response_xml, nice_identifier=None, ignored=None, post_processor=None ): """ Parse xml result into list of stories :param response_xml:xml xml result from remote call :param nice_identifier:string story title substring :param ignored:list list of story ids to be ignored :param post_processor:JiraStoryProcessor Subclass of JiraStoryProcessor :return:StoryCollection list of Story(s) """ stories = StoryCollection() xml_stories = response_xml[0].findall('item') for s in xml_stories: story = Story() story.id = s.find('key').text # check if the story should be ignored (see ignore in config) if ignored is not None and story.id in ignored: print 'story {} is ignored'.format(story.id) continue # check if the story is a 'nice to have' if nice_identifier is not None: story.is_nice = s.find('title').text.find(nice_identifier) != -1 # status story.status = int(s.find('status').get('id')) # business value try: story.business_value = float( s.find( './customfields/customfield/[@id="customfield_10064"]/customfieldvalues/customfieldvalue' ).text ) except AttributeError: print 'Story {} has no business value defined, 0 taken as default'.format(story.id) # story points try: story.story_points = float( s.find( './customfields/customfield/[@id="customfield_10040"]/customfieldvalues/customfieldvalue' ).text ) except AttributeError: print 'Story {} has no story points defined, 0 taken as default'.format(story.id) # post processor if post_processor is not None: story = post_processor.post_process(story) if story is None: continue # other attributes if s.find('project') is not None and s.find('project').get('id') is not None: story.project_id = s.find('project').get('id') story.project_name = s.find('project').text if s.find('fixVersion') is not None: story.sprint_name = s.find('fixVersion').text stories.append(story) return stories