def test_date_convert_pass2(): content = date_convert('2008-01-14T04:33:35Z') assert content == '2008-01-14'
def test_date_convert_pass(): content = date_convert('10-10-2019') assert content == '2019-10-10'
def _converter(self): """ A tuple of formatted tag name, description, created at and the compare links. Returns ------- tuple: tuple A tuple of list. """ temp = self.releases()['data']['repository']['releases']['edges'] temp_l = [] self.total_number_tags = sum(1 for k in temp if k['node']['tag']['name']) print(description(provider=self.info.resource, repo_name=self.info.name, tags_number=self.total_number_tags)) if self.file_type == 'markdown': self.all_content.append(self._header()) for count, edge in enumerate(temp): self.iter_count = count temp_l.append(edge['node']['tag']['name']) self.tag_name = edge['node']['tag']['name'] self.description = edge['node']['description'].replace('\r\n', '\n') self.date = date_convert(edge['node']['createdAt']) self.author = edge['node']['author']['login'] self.all_content.append(self._body()) pair = list(['{}...{}'.format(a, b) for a, b in zip(temp_l, ['HEAD'] + temp_l[:-1])]) for count, tags in enumerate(pair): if count < 1: self.all_content.append('[Unreleased]: ' + self.compare_url + tags + '\n') else: self.all_content.append('[' + tags.split('...')[1] + ']: ' + self.compare_url + tags + '\n') return tuple(self.all_content) elif self.file_type == 'json': temp_l2 = [] tag_comp_url_temp = [] self.list_descriptions.insert(0, self._dict_data_template(tag_name='Unreleased', description='', date='')) for count, edge in enumerate(temp): self.iter_count = count temp_l2.append(edge['node']['tag']['name']) self.list_descriptions.append(self._dict_data_template(tag_name=edge['node']['tag']['name'], description=edge['node'][ 'description'].replace('\r\n', '\n'), date=date_convert( edge['node']['createdAt']))) pair = list(['{}...{}'.format(a, b) for a, b in zip(temp_l2, ['HEAD'] + temp_l2[:-1])]) for tags in pair: tag_comp_url_temp.append(self.compare_url + tags) for count, urls in enumerate(tag_comp_url_temp): self.list_descriptions[count]['compareUrl'] = urls
def test_date_convert_fail(): with pytest.raises(ValueError, message="Unknown string format"): content = date_convert('10-10-2019T12:12:12z')
def _converter(self): """ A tuple of formatted tag name, description, created at and the compare links. :return: :type: tuple -- A tuple of list. """ temp = self.releases() temp_l = [] self.total_number_tags = sum(1 for k in temp if k['name']) print( description(provider=self.info.resource, repo_name=self.info.name, tags_number=self.total_number_tags)) if self.file_type == 'markdown': self.all_content.append(self._header()) for count, content in enumerate(temp): self.iter_count = count temp_l.append(content['name']) self.tag_name = content['name'] self.description = content['release']['description'].replace( '\r\n', '\n') self.date = date_convert(content['commit']['created_at']) self.all_content.append(self._body()) pair = list([ '{}...{}'.format(a, b) for a, b in zip(temp_l, ['HEAD'] + temp_l[:-1]) ]) self.all_content.append('\n') for count, tags in enumerate(pair): if count < 1: self.all_content.append('[Unreleased]: ' + self.compare_url + tags + '\n') else: self.all_content.append('[' + tags.split('...')[1] + ']: ' + self.compare_url + tags + '\n') return tuple(self.all_content) elif self.file_type == 'json': temp_l2 = [] tag_comp_url_temp = [] self.list_descriptions.insert( 0, self._dict_data_template(tag_name='Unreleased', description='', date='')) for count, content in enumerate(temp): self.iter_count = count temp_l2.append(content['name']) self.list_descriptions.append( self._dict_data_template( tag_name=content['name'], description=content['release']['description'].replace( '\r\n', '\n'), date=date_convert(content['commit']['created_at']))) pair = list([ '{}...{}'.format(a, b) for a, b in zip(temp_l2, ['HEAD'] + temp_l2[:-1]) ]) for tags in pair: tag_comp_url_temp.append(self.compare_url + tags) for count, urls in enumerate(tag_comp_url_temp): self.list_descriptions[count]['compareUrl'] = urls elif self.file_type == 'rst': raise NotImplementedError("Coming soon")