def test_discoverMissingLinks_containsImageAndLink(self):

        text = "This has a missing ![image link][] definition and a [normal link][]."

        expected = "This has a missing ![image link][] definition and a [normal link][].\n\n[image link]: 404\n[normal link]: 404"
        actual = link_utils.discover_missing_links(text)

        self.assertEqual(actual, expected)
    def test_discoverMissingLinks(self):

        text = "This has a missing [link][] definition."

        expected = "This has a missing [link][] definition.\n\n[link]: 404"
        actual = link_utils.discover_missing_links(text)

        self.assertEqual(actual, expected)
    def test_discoverMissingLinks_withDefaultDefinition(self):

        text = "This has a missing [link][] definition."
        default_definition = "this is missing"

        expected = "This has a missing [link][] definition.\n\n[link]: " + default_definition
        actual = link_utils.discover_missing_links(text, default_definition=default_definition)

        self.assertEqual(actual, expected)
    def test_discoverMissingLinks_appendsToExistingGroup_atEnd(self):

        text = """This has a missing [link][] definition but there are existing [definitions][].

[definitions]: http://link.com"""

        expected = """This has a missing [link][] definition but there are existing [definitions][].

[definitions]: http://link.com
[link]: 404"""
        actual = link_utils.discover_missing_links(text)

        self.assertEqual(actual, expected)
Esempio n. 5
0
    def test_cleanToClean(self):

        with open(CLEAN_FILE_PATH) as clean_file:
            expected = clean_file.read()

        actual = bold_utils.convert_bolds(expected)
        actual = header_utils.fix_header_balancing(actual)
        actual = horizontal_rule_utils.convert_horizontal_rules(actual)
        actual = italic_utils.convert_italics(actual)
        actual = link_utils.discover_missing_links(actual)
        actual = link_utils.format_link_reference_definitions(actual)
        actual = list_utils.alternate_unordered_list_delimiters(actual)
        actual = list_utils.fix_ordered_list_numbering(actual)
        actual = whitespace_utils.trim_nonbreaking_whitespace(actual)

        self.assertEqual(actual, expected)
Esempio n. 6
0
    def test_dirtyToClean_atx_unbalanced(self):

        with open(DIRTY_FILE_PATH) as dirty_file:
            text = dirty_file.read()
        with open(CLEAN_ANY_HEADER_UNBALANCED_FILE_PATH) as clean_file:
            expected = clean_file.read()

        actual = bold_utils.convert_bolds(text)
        actual = header_utils.fix_header_balancing(actual, balancing=header_utils.UNBALANCED)
        actual = horizontal_rule_utils.convert_horizontal_rules(actual)
        actual = italic_utils.convert_italics(actual)
        actual = link_utils.discover_missing_links(actual)
        actual = link_utils.format_link_reference_definitions(actual)
        actual = list_utils.alternate_unordered_list_delimiters(actual)
        actual = list_utils.fix_ordered_list_numbering(actual)
        actual = whitespace_utils.trim_nonbreaking_whitespace(actual)

        self.assertEqual(actual, expected)
    def test_discoverMissingLinks_appendsToExistingGroup_sameLinkMissingMultiplePlaces(self):

        text = """This has a missing [link][] definition but there are existing [definitions][].

[definitions]: http://link.com

More the same [link][] is [here][].

[here]: http://link.com"""

        expected = """This has a missing [link][] definition but there are existing [definitions][].

[definitions]: http://link.com
[link]: 404

More the same [link][] is [here][].

[here]: http://link.com
[link]: 404"""
        actual = link_utils.discover_missing_links(text)

        self.assertEqual(actual, expected)