complete unit tests coverage
complete all quality warnings
This commit is contained in:
@@ -42,31 +42,31 @@ def _ChangelogFormaterRecordType(Klass: type) -> type:
|
||||
|
||||
|
||||
class ChangeLogFormater(ABC):
|
||||
"""ChangeLogFormater class
|
||||
|
||||
prefix: str = "^\s+"
|
||||
title: str = "Others :"
|
||||
keywords: list[str] = []
|
||||
This class is the base formater class.
|
||||
|
||||
This class is for:
|
||||
|
||||
- classifying message: CheckLine() and CheckLine_keywords()
|
||||
- storing lines: Clear() and PushLine()
|
||||
- returning the formated output: Render() and RenderLines()
|
||||
|
||||
|
||||
/// warning
|
||||
this class does not aim to be instantiated by user.
|
||||
///
|
||||
"""
|
||||
|
||||
prefix: None | str = None
|
||||
title: None | str = None
|
||||
keywords: None | list[str] = None
|
||||
priority: int = 0
|
||||
|
||||
_lines: list[str] = []
|
||||
|
||||
def __init__(self):
|
||||
"""ChangeLogFormater class constructor
|
||||
|
||||
This class is the base formater class.
|
||||
|
||||
This class is for:
|
||||
|
||||
- classifying message: CheckLine() and CheckLine_keywords()
|
||||
- storing lines: Clear() and PushLine()
|
||||
- returning the formated output: Render() and RenderLines()
|
||||
|
||||
|
||||
/// warning
|
||||
this class does not aim to be instantiated by user.
|
||||
///
|
||||
|
||||
"""
|
||||
"""ChangeLogFormater class constructor"""
|
||||
self._lines = []
|
||||
|
||||
def Clear(self) -> None:
|
||||
@@ -174,12 +174,11 @@ class ChangeLogFactory:
|
||||
"""
|
||||
if self is not None:
|
||||
self.ar_FormaterKlass = _savedFormaterList.copy()
|
||||
self.ar_Formater = dict()
|
||||
self.ar_Formater = {}
|
||||
for FormaterKlass in self.ar_FormaterKlass:
|
||||
self.ar_Formater[FormaterKlass.__name__] = FormaterKlass()
|
||||
return self
|
||||
else:
|
||||
ChangeLogFactory.ar_FormaterKlass = _savedFormaterList.copy()
|
||||
ChangeLogFactory.ar_FormaterKlass = _savedFormaterList.copy()
|
||||
return None
|
||||
|
||||
def RegisterFormater(self, FormaterKlass: ChangeLogFormater) -> None:
|
||||
"""Register a new formater in the current instance
|
||||
@@ -276,7 +275,7 @@ class ChangeLogFactory:
|
||||
if (lineWordsCount > 1) and (not re.match(self.checkCommentPattern, line)):
|
||||
if self._ProcessLineMain(line) is True:
|
||||
continue
|
||||
elif lineWordsCount > 2:
|
||||
if lineWordsCount > 2:
|
||||
Lines2ndRound.append(line)
|
||||
|
||||
for line in Lines2ndRound:
|
||||
@@ -330,8 +329,8 @@ for RecordType, Config in {
|
||||
),
|
||||
"wip": ( 0, ["temp", ],
|
||||
"Work in progress changes :construction: :",
|
||||
),
|
||||
"doc": ( 0, [ "doc", "manual"],
|
||||
),
|
||||
"doc": ( 0, [ "doc", "manual"],
|
||||
"Documentations :book: :",
|
||||
),
|
||||
"style": ( 5, ["beautify", ],
|
||||
@@ -340,13 +339,13 @@ for RecordType, Config in {
|
||||
"refactor": ( 0, [],
|
||||
"Refactorings :recycle: :"
|
||||
),
|
||||
"ci": ( 0, ["jenkins", "git"],
|
||||
"ci": ( 0, ["jenkins", "git"],
|
||||
"Continuous Integration :cyclone: :"
|
||||
),
|
||||
"test": ( -5, ["unittest", "check", "testing"],
|
||||
"test": ( -5, ["unittest", "check", "testing"],
|
||||
"Testings :vertical_traffic_light: :"
|
||||
),
|
||||
"build": ( 0, ["compile", "version"],
|
||||
"build": ( 0, ["compile", "version"],
|
||||
"Builds :package: :"
|
||||
),
|
||||
# fmt: on
|
||||
|
||||
@@ -15,10 +15,10 @@ class Testtest_module(unittest.TestCase):
|
||||
def setUp(self):
|
||||
ChangeLogFactory.ResetFormaterList()
|
||||
|
||||
def simplegeneration(self, inputstr, teststrs: list[str]):
|
||||
def simplegeneration(self, inputstr, teststrs: list[str], withunknown: bool = False):
|
||||
hdlr = ChangeLogFactory()
|
||||
hdlr.ProcessFullChangelog(inputstr)
|
||||
changelog = hdlr.RenderFullChangelog()
|
||||
changelog = hdlr.RenderFullChangelog(include_unknown=withunknown)
|
||||
for test in teststrs:
|
||||
self.assertIn(test, changelog)
|
||||
|
||||
@@ -52,6 +52,15 @@ class Testtest_module(unittest.TestCase):
|
||||
self.assertIn("testdoc", changelog[5])
|
||||
self.assertIn("testtest", changelog[7])
|
||||
|
||||
def test_simplegeneration_toosmall(self):
|
||||
self.simplegeneration("one", [], True)
|
||||
self.simplegeneration("one two", [], True)
|
||||
self.simplegeneration("one two three", ["one two three"], True)
|
||||
|
||||
def test_simplegeneration_unknown(self):
|
||||
self.simplegeneration("one two three", ["one two three"], True)
|
||||
self.simplegeneration("one two three", [""], False)
|
||||
|
||||
def test_simplegeneration_multiple(self):
|
||||
raw = "break: testbreak" + "\n" + "doc: testdoc" + "\n" + "style: teststyle"
|
||||
self.simplegeneration(raw, ["testbreak", "testdoc", "teststyle"])
|
||||
|
||||
Reference in New Issue
Block a user