fix and complete unittest
update documentation: samples + custom formaters
This commit is contained in:
@@ -20,7 +20,7 @@ class Testtest_module(unittest.TestCase):
|
||||
self.assertIn(test, changelog)
|
||||
|
||||
def test_simplegeneration_ignored2(self):
|
||||
raw = "break: testbreak break" + "\n" + "#docs: testdoc doc" + "\n" + "#style: teststyle beautify" + "\n" + "//test: testtest check"
|
||||
raw = "break: testbreak break" + "\n" + "#doc: testdoc doc" + "\n" + "#style: teststyle beautify" + "\n" + "//test: testtest check"
|
||||
|
||||
hdlr = pychangelogfactory.ChangeLogFactory(raw)
|
||||
changelog = hdlr.RenderFullChangelog()
|
||||
@@ -31,7 +31,7 @@ class Testtest_module(unittest.TestCase):
|
||||
self.assertNotIn("testtest", changelog)
|
||||
|
||||
def test_simplegeneration_ignored(self):
|
||||
raw = "break: testbreak" + "\n" + "#docs: testdoc" + "\n" + "#style: teststyle" + "\n" + "//test: testtest"
|
||||
raw = "break: testbreak" + "\n" + "#doc: testdoc" + "\n" + "#style: teststyle" + "\n" + "//test: testtest"
|
||||
|
||||
hdlr = pychangelogfactory.ChangeLogFactory(raw)
|
||||
changelog = hdlr.RenderFullChangelog()
|
||||
@@ -41,7 +41,7 @@ class Testtest_module(unittest.TestCase):
|
||||
self.assertNotIn("testtest", changelog)
|
||||
|
||||
def test_simplegeneration_order(self):
|
||||
raw = "break: testbreak" + "\n" + "docs: testdoc" + "\n" + "style: teststyle" + "\n" + "test: testtest"
|
||||
raw = "break: testbreak" + "\n" + "doc: testdoc" + "\n" + "style: teststyle" + "\n" + "test: testtest"
|
||||
hdlr = pychangelogfactory.ChangeLogFactory(raw)
|
||||
changelog = hdlr.RenderFullChangelog().splitlines()
|
||||
self.assertIn("testbreak", changelog[1])
|
||||
@@ -50,7 +50,7 @@ class Testtest_module(unittest.TestCase):
|
||||
self.assertIn("testtest", changelog[7])
|
||||
|
||||
def test_simplegeneration_multiple(self):
|
||||
raw = "break: testbreak" + "\n" + "docs: testdoc" + "\n" + "style: teststyle"
|
||||
raw = "break: testbreak" + "\n" + "doc: testdoc" + "\n" + "style: teststyle"
|
||||
self.simplegeneration(raw, ["testbreak", "testdoc", "teststyle"])
|
||||
|
||||
def test_simplegeneration_breaking(self):
|
||||
@@ -91,7 +91,7 @@ class Testtest_module(unittest.TestCase):
|
||||
self.simplegeneration("test temp dummy1 dummy2", ["test temp"])
|
||||
|
||||
def test_simplegeneration_docs(self):
|
||||
self.simplegeneration("docs: teststring", ["teststring"])
|
||||
self.simplegeneration("doc: teststring", ["teststring"])
|
||||
self.simplegeneration("test doc dummy1 dummy2", ["test doc"])
|
||||
|
||||
def test_simplegeneration_style(self):
|
||||
@@ -119,31 +119,74 @@ class Testtest_module(unittest.TestCase):
|
||||
def test_simplegeneration_revert(self):
|
||||
self.simplegeneration("revert: teststring", ["~~teststring~~"])
|
||||
|
||||
# fmt: off
|
||||
raw_changelog = (
|
||||
"feat: add a nice feature to the project\n"
|
||||
"style: reindent the full Foo class\n"
|
||||
"security: fix a security leak on the Foo2 component"
|
||||
"security: fix a security issue on the Foo2 component\n"
|
||||
"security: fix another security problem on the Foo2 component\n"
|
||||
"improve core performances by reducing complexity\n"
|
||||
"some random changes in the text content\n"
|
||||
)
|
||||
expected_formated = (
|
||||
"#### Features :sparkles::\n"
|
||||
"#### Features :sparkles: :\n"
|
||||
"> add a nice feature to the project\n"
|
||||
"#### Security :shield::\n"
|
||||
"> fix a security leak on the Foo2 component\n"
|
||||
"#### Style :art::\n"
|
||||
"#### Security :shield: :\n"
|
||||
"> fix a security issue on the Foo2 component\n"
|
||||
"> fix another security problem on the Foo2 component\n"
|
||||
"#### Performance Enhancements :rocket: :\n"
|
||||
"> improve core performances by reducing complexity\n"
|
||||
"#### Style :art: :\n"
|
||||
"> reindent the full Foo class\n"
|
||||
"#### Others :question: :\n"
|
||||
"> some random changes in the text content\n"
|
||||
)
|
||||
# fmt: on
|
||||
|
||||
def test_sample(self):
|
||||
hdlr = pychangelogfactory.ChangeLogFactory(self.raw_changelog)
|
||||
changelog = hdlr.RenderFullChangelog()
|
||||
changelog = hdlr.RenderFullChangelog(include_unknown=True)
|
||||
self.assertEqual(changelog, self.expected_formated)
|
||||
|
||||
def test_sample_aio(self):
|
||||
changelog = pychangelogfactory.ChangeLogFactory(self.raw_changelog).RenderFullChangelog()
|
||||
changelog = pychangelogfactory.ChangeLogFactory(self.raw_changelog).RenderFullChangelog(include_unknown=True)
|
||||
print(changelog)
|
||||
self.assertEqual(changelog, self.expected_formated)
|
||||
|
||||
def test_sample_exploded(self):
|
||||
hdlr = pychangelogfactory.ChangeLogFactory()
|
||||
hdlr.ProcessFullChangelog(self.raw_changelog)
|
||||
changelog = hdlr.RenderFullChangelog()
|
||||
changelog = hdlr.RenderFullChangelog(include_unknown=True)
|
||||
self.assertEqual(changelog, self.expected_formated)
|
||||
|
||||
|
||||
class Testtest_module_othercontext(unittest.TestCase):
|
||||
def test_custom(self):
|
||||
|
||||
from src.pychangelogfactory import ChangeLogFormater, ChangeLogFormaterRecordType, ChangeLogFactory
|
||||
|
||||
@ChangeLogFormaterRecordType
|
||||
class ChangeLogFormater_TEST(ChangeLogFormater):
|
||||
"""My formater"""
|
||||
|
||||
prefix: str = "mytag"
|
||||
title: str = "My Title :"
|
||||
keywords: list[str] = ["foo", "42"]
|
||||
priority: int = 10
|
||||
|
||||
# fmt: off
|
||||
raw_changelog = ("mytag: add a nice feature to the project\n"
|
||||
"foo modification in my file\n"
|
||||
"need 42 coffee\n"
|
||||
)
|
||||
expected_formated = (
|
||||
"#### My Title :\n"
|
||||
"> add a nice feature to the project\n"
|
||||
"> foo modification in my file\n"
|
||||
"> need 42 coffee\n"
|
||||
)
|
||||
# fmt: on
|
||||
|
||||
hdlr = ChangeLogFactory(raw_changelog)
|
||||
changelog = hdlr.RenderFullChangelog(include_unknown=True)
|
||||
self.assertEqual(changelog, expected_formated)
|
||||
|
||||
Reference in New Issue
Block a user