Commit c60d0e28 authored by Greg Wilson's avatar Greg Wilson
Browse files

Merge pull request #165 from abought/fail_fixme

Validator should fail when FIXME present
parents 11bb30f1 886d47de
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -74,6 +74,19 @@ class MarkdownValidator(object):
        ast = parser.parse(markdown)
        return ast

    def _validate_no_fixme(self):
        """Validate that the file contains no lines marked 'FIXME'
        This will be based on the raw markdown, not the ast"""
        valid = True
        for i, line in enumerate(self.markdown.splitlines()):
            if re.search("FIXME", line, re.IGNORECASE):
                logging.error(
                    "In {0}: "
                    "Line {1} contains FIXME, indicating "
                    "work in progress".format(self.filename, i+1))
                valid = False
        return valid

    def _validate_hrs(self):
        """Validate header

@@ -418,7 +431,8 @@ class MarkdownValidator(object):

        Error trapping is handled by the validate() wrapper method.
        """
        tests = [self._validate_doc_headers(),
        tests = [self._validate_no_fixme(),
                 self._validate_doc_headers(),
                 self._validate_section_heading_order(),
                 self._validate_callouts(),
                 self._validate_links()]
+11 −0
Original line number Diff line number Diff line
@@ -353,6 +353,17 @@ A spacer paragraph
""")
        self.assertFalse(validator._validate_callouts())

    def test_fail_if_fixme_present_all_caps(self):
        """Validation should fail if a line contains the word FIXME (exact)"""
        validator = self._create_validator("""Incomplete sentence (FIXME).""")
        self.assertFalse(validator._validate_no_fixme())

    def test_fail_if_fixme_present_mixed_case(self):
        """Validation should fail if a line contains the word FIXME
        (in any capitalization)"""
        validator = self._create_validator("""Incomplete sentence (FiXmE).""")
        self.assertFalse(validator._validate_no_fixme())


class TestTopicPage(BaseTemplateTest):
    """Verifies that the topic page validator works as expected"""