def test_render_markdown_to_new_file(self): gc = GenerateChangelog(**DEFAULT_ARGS) gc.render_markdown_to_file(file_path=os.path.join( TEST_FOLDER, 'CHANGELOG.md'), entry_id='1.0.0') self.assertFileContentsEqual(file_a='CHANGELOG.md', file_b=os.path.join( 'fixtures', 'new_file_output.md'))
def test_render_markdown_author_by_change_type_template(self): generate_changelog = GenerateChangelog( template_name='author_by_change_type', **DEFAULT_ARGS) result = generate_changelog.render_markdown() with open(f'{TEST_FOLDER}/fixtures/author_by_change_type_template.md' ) as reader: print(result) assert result == reader.read()
def test_expression_statements(self): gc = GenerateChangelog( **DEFAULT_ARGS, **{ 'template_file': os.path.join(TEST_FOLDER, 'fixtures', 'template_expression_statement.j2') }) result = gc.render_markdown() assert result == "I appended successfully"
def test_template_includes(self): gc = GenerateChangelog( **DEFAULT_ARGS, **{ 'template_file': os.path.join(TEST_FOLDER, 'fixtures', 'template_with_includes.j2') }) result = gc.render_markdown() assert result == "# I AM INCLUSIVE\n## I AM INCLUDED"
def test_render_markdown_jira_id_by_change_type_template(self): generate_changelog = GenerateChangelog( template_name='jira_id_by_change_type', custom_attributes={ 'jira_id': { 'derived_from': 'message', 'pattern': r'^\w+-\d+' } }, **DEFAULT_ARGS) result = generate_changelog.render_markdown() with open(f'{TEST_FOLDER}/fixtures/jira_id_by_change_type_template.md' ) as reader: print(result) assert result == reader.read()
def test_render_markdown_root_folder_all_commits_template(self): generate_changelog = GenerateChangelog( template_name='root_folder_all_commits', custom_attributes={ 'root_folder': { 'derived_from': 'file_path', 'pattern': r'^([^/]+)/|' } }, **DEFAULT_ARGS) result = generate_changelog.render_markdown() with open(f'{TEST_FOLDER}/fixtures/root_folder_all_commits_template.md' ) as reader: print(result) assert result == reader.read()
def test_render_markdown_throws_with_unrecognised_template_name(self): with self.assertRaises(ValueError) as cm: GenerateChangelog(template_name='unrecognised_template', **DEFAULT_ARGS) assert str(cm.exception) == ( "unrecognised_template is not a template bundled with this " "version of Sam's Generate Changelog")
def test_render_markdown_root_folder_all_commits_template_throws_without_custom_attribute( self): with self.assertRaises(ValueError) as cm: GenerateChangelog(template_name='root_folder_all_commits', **DEFAULT_ARGS) assert str(cm.exception) == ( 'root_folder_all_commits requires a custom attribute specification' ' to be provided, please consult the documentation')