reached 100% testing cover

This commit is contained in:
Alvaro Andrés Rodríguez Scelza 2019-06-13 21:33:58 -03:00
parent a9d54a63fc
commit 8e79502b8a
10 changed files with 13 additions and 0 deletions

View file

@ -7,6 +7,7 @@ from pre_commit_hooks.loaderon_hooks.util.template_methods.lines_checker_templat
class ClassDocstringChecker(LinesCheckerTemplateMethod): class ClassDocstringChecker(LinesCheckerTemplateMethod):
def _check_line(self): def _check_line(self):
super(ClassDocstringChecker, self)._check_line()
regular_expression = r'^(\t| )*class .+\(.*\):' regular_expression = r'^(\t| )*class .+\(.*\):'
pattern = re.compile(regular_expression) pattern = re.compile(regular_expression)
if pattern.match(self._file_line): if pattern.match(self._file_line):

View file

@ -15,6 +15,7 @@ class LinesChecker(LinesCheckerTemplateMethod):
self.check_arguments_size_match(self.args.line_to_check, self.args.regexp_to_match) self.check_arguments_size_match(self.args.line_to_check, self.args.regexp_to_match)
def _check_line(self): def _check_line(self):
super(LinesChecker, self)._check_line()
for line_index, line_to_check in enumerate(self.args.line_to_check): for line_index, line_to_check in enumerate(self.args.line_to_check):
line_to_check_pattern = re.compile(line_to_check) line_to_check_pattern = re.compile(line_to_check)
if line_to_check_pattern.match(self._file_line): if line_to_check_pattern.match(self._file_line):

View file

@ -25,6 +25,7 @@ class LocationChecker(FileCheckerTemplateMethod):
def _check_file(self): def _check_file(self):
"""Check filename location against enabled directories and their enabled files.""" """Check filename location against enabled directories and their enabled files."""
super(LocationChecker, self)._check_file()
self.check_arguments_size_match(self.args.directories, self.args.files) self.check_arguments_size_match(self.args.directories, self.args.files)
file_directory_path = os.path.dirname(self.filename) file_directory_path = os.path.dirname(self.filename)
file_name = os.path.basename(self.filename) file_name = os.path.basename(self.filename)

View file

@ -19,6 +19,7 @@ class PylintChecker(FileCheckerTemplateMethod):
self.parser.add_argument('-e', '--exclude', help='Excluded files to check.') self.parser.add_argument('-e', '--exclude', help='Excluded files to check.')
def _check_file(self): def _check_file(self):
super(PylintChecker, self)._check_file()
try: try:
self.run_pylint_except_in_excluded_files() self.run_pylint_except_in_excluded_files()
except SystemExit as exception: except SystemExit as exception:

View file

@ -9,6 +9,7 @@ class XMLEncodingChecker(FileCheckerTemplateMethod):
self.parser.add_argument('-e', '--encoding', help='Desired encoding.') self.parser.add_argument('-e', '--encoding', help='Desired encoding.')
def _check_file(self): def _check_file(self):
super(XMLEncodingChecker, self)._check_file()
first_line = read_file_line(self.filename) first_line = read_file_line(self.filename)
desired_encoding = self.args.encoding.rstrip() desired_encoding = self.args.encoding.rstrip()
first_line = first_line.rstrip('\n') first_line = first_line.rstrip('\n')

View file

@ -18,6 +18,7 @@ class ModelNameAttributeChecker(FileBunchesLinesCheckerTemplateMethod):
self.__inherit_line = '' self.__inherit_line = ''
def _get_regexp(self): def _get_regexp(self):
super(ModelNameAttributeChecker, self)._get_regexp()
return r'^(\t| )*class.+' return r'^(\t| )*class.+'
def _check_file(self): def _check_file(self):
@ -39,6 +40,7 @@ class ModelNameAttributeChecker(FileBunchesLinesCheckerTemplateMethod):
We will use this inherited method (which runs through all file lines) in order to gather lines that are required We will use this inherited method (which runs through all file lines) in order to gather lines that are required
to perform the lines bunch check. to perform the lines bunch check.
""" """
super(ModelNameAttributeChecker, self)._check_line()
if self.__name_pattern.match(self._file_line): if self.__name_pattern.match(self._file_line):
self.__name_line = self._file_line.strip('_name = ') self.__name_line = self._file_line.strip('_name = ')
if self.__inherit_pattern.match(self._file_line): if self.__inherit_pattern.match(self._file_line):

View file

@ -17,9 +17,11 @@ class ViewFieldsOrderChecker(FileBunchesCheckerTemplateMethod):
self._model_line = None self._model_line = None
def _get_regexp(self): def _get_regexp(self):
super(ViewFieldsOrderChecker, self)._get_regexp()
return r'^(\t| )*<record id=.+ model="ir.ui.view">(\t| )*' return r'^(\t| )*<record id=.+ model="ir.ui.view">(\t| )*'
def _check_bunch(self): def _check_bunch(self):
super(ViewFieldsOrderChecker, self)._check_bunch()
self._record_line = self._bunch_of_lines[0].strip() self._record_line = self._bunch_of_lines[0].strip()
self._name_line = self._bunch_of_lines[1] self._name_line = self._bunch_of_lines[1]
self._model_line = self._bunch_of_lines[2] self._model_line = self._bunch_of_lines[2]

View file

@ -17,9 +17,11 @@ class FileBunchesLinesCheckerTemplateMethod(FileBunchesCheckerTemplateMethod, Li
This method uses LinesCheckerTemplateMethod's _check_lines. Which receives self._file_lines. In this case, our This method uses LinesCheckerTemplateMethod's _check_lines. Which receives self._file_lines. In this case, our
'file lines' will be the bunches of lines got by split_by_classes. 'file lines' will be the bunches of lines got by split_by_classes.
""" """
super(FileBunchesLinesCheckerTemplateMethod, self)._check_bunch()
self._file_lines = self._bunch_of_lines self._file_lines = self._bunch_of_lines
self._check_lines() self._check_lines()
@abstractmethod @abstractmethod
def _check_line(self): def _check_line(self):
super(FileBunchesLinesCheckerTemplateMethod, self)._check_line()
pass pass

View file

@ -11,6 +11,7 @@ class FileBunchesCheckerTemplateMethod(FileCheckerTemplateMethod):
self._bunch_of_lines = [] self._bunch_of_lines = []
def _check_file(self): def _check_file(self):
super(FileBunchesCheckerTemplateMethod, self)._check_file()
regexp = self._get_regexp() regexp = self._get_regexp()
bunches_of_lines = split_by_regexp(self.filename, regexp) bunches_of_lines = split_by_regexp(self.filename, regexp)
for self._bunch_of_lines in bunches_of_lines: for self._bunch_of_lines in bunches_of_lines:

View file

@ -13,6 +13,7 @@ class LinesCheckerTemplateMethod(FileCheckerTemplateMethod):
self._file_line_index = 0 self._file_line_index = 0
def _check_file(self): def _check_file(self):
super(LinesCheckerTemplateMethod, self)._check_file()
self._file_lines = read_file_lines(self.filename) self._file_lines = read_file_lines(self.filename)
self._check_lines() self._check_lines()