<commit_before># coding:utf-8
from base import TestBase

class TestAttribute(TestBase):
    """Test of attributes"""

    # for debug
    # def tearDown(self):
    #     pass

    # -----------------
    # Auto link

    autolink_text = \
"""

<!-- MarkdownTOC {0} -->

<!-- /MarkdownTOC -->

# Foo Bar
"""

    def test_autolink_default(self):
        """Default Auto link is false"""
        toc_txt = self.commonSetup(self.autolink_text.format(''))
        self.assert_In('- Foo Bar', toc_txt)

    def test_autolink_true(self):
        toc_txt = self.commonSetup(self.autolink_text.format('autolink=true'))
        self.assert_In('- [Foo Bar][foo-bar]', toc_txt)

    def test_autolink_false(self):
        toc_txt = self.commonSetup(self.autolink_text.format('autolink=false'))
        self.assert_In('- Foo Bar', toc_txt)


    # -----------------
    # Bracket

    # TODO: How can we remove "autolink=true" only in these tests below ?

    bracket_text = \
"""

<!-- MarkdownTOC autolink=true {0} -->

<!-- /MarkdownTOC -->

# foo bar
"""
    def test_bracket_default(self):
        """Default Bracket is square"""
        toc_txt = self.commonSetup(self.bracket_text.format(''))
        self.assert_In('- [foo bar][foo-bar]', toc_txt)

    def test_bracket_square(self):
        toc_txt = self.commonSetup(self.bracket_text.format('bracket=square'))
        self.assert_In('- [foo bar][foo-bar]', toc_txt)

    def test_bracket_round(self):
        toc_txt = self.commonSetup(self.bracket_text.format('bracket=round'))
        self.assert_In('- [foo bar](#foo-bar)', toc_txt)

    # -----------------
    # Depth

    depth_text = \
"""

<!-- MarkdownTOC {0} -->

<!-- /MarkdownTOC -->

# heading 1
## heading 2
### heading 3
#### heading 4
##### heading 5
"""
    def test_depth_default(self):
        """Default Depth is 2"""
        toc_txt = self.commonSetup(self.depth_text.format(''))
        self.assert_In('- heading 1', toc_txt)
        self.assert_In('- heading 2', toc_txt)
        self.assert_NotIn('- heading 3', toc_txt)
        self.assert_NotIn('- heading 4', toc_txt)
        self.assert_NotIn('- heading 5', toc_txt)

    def test_depth_0(self):
        """Depth 0 means no limit"""
        toc_txt = self.commonSetup(self.depth_text.format('depth=0'))
        self.assert_In('- heading 1', toc_txt)
        self.assert_In('- heading 2', toc_txt)
        self.assert_In('- heading 3', toc_txt)
        self.assert_In('- heading 4', toc_txt)
        self.assert_In('- heading 5', toc_txt)

    def test_depth_1(self):
        toc_txt = self.commonSetup(self.depth_text.format('depth=1'))
        self.assert_In('- heading 1', toc_txt)
        self.assert_NotIn('- heading 2', toc_txt)
        self.assert_NotIn('- heading 3', toc_txt)
        self.assert_NotIn('- heading 4', toc_txt)
        self.assert_NotIn('- heading 5', toc_txt)

    def test_depth_2(self):
        toc_txt = self.commonSetup(self.depth_text.format('depth=2'))
        self.assert_In('- heading 1', toc_txt)
        self.assert_In('- heading 2', toc_txt)
        self.assert_NotIn('- heading 3', toc_txt)
        self.assert_NotIn('- heading 4', toc_txt)
        self.assert_NotIn('- heading 5', toc_txt)

    def test_depth_3(self):
        toc_txt = self.commonSetup(self.depth_text.format('depth=3'))
        self.assert_In('- heading 1', toc_txt)
        self.assert_In('- heading 2', toc_txt)
        self.assert_In('- heading 3', toc_txt)
        self.assert_NotIn('- heading 4', toc_txt)
        self.assert_NotIn('- heading 5', toc_txt)

    def test_depth_4(self):
        toc_txt = self.commonSetup(self.depth_text.format('depth=4'))
        self.assert_In('- heading 1', toc_txt)
        self.assert_In('- heading 2', toc_txt)
        self.assert_In('- heading 3', toc_txt)
        self.assert_In('- heading 4', toc_txt)
        self.assert_NotIn('- heading 5', toc_txt)

    def test_depth_5(self):
        toc_txt = self.commonSetup(self.depth_text.format('depth=5'))
        self.assert_In('- heading 1', toc_txt)
        self.assert_In('- heading 2', toc_txt)
        self.assert_In('- heading 3', toc_txt)
        self.assert_In('- heading 4', toc_txt)
        self.assert_In('- heading 5', toc_txt)

    # -----------------
    # Auto anchor

    autoanchor_text = \
"""

<!-- MarkdownTOC autolink=true {0} -->

<!-- /MarkdownTOC -->

# Changelog

# Glossary

# API Specification
"""
    def get_body_text():
        pass

    def test_autoanchor_false(self):
        """Default Auto Anchor is false"""
        body_txt = self.commonSetupAndUpdateGetBody(self.autoanchor_text.format(''))
        self.assert_NotIn('<a name="changelog"></a>', body_txt)
        self.assert_NotIn('<a name="glossary"></a>', body_txt)
        self.assert_NotIn('<a name="api-specification"></a>', body_txt)

    def test_autoanchor_true(self):
        body_txt = self.commonSetupAndUpdateGetBody(self.autoanchor_text.format('autoanchor=true'))
        self.assert_In('<a name="changelog"></a>\n# Changelog', body_txt)
        self.assert_In('<a name="glossary"></a>\n# Glossary', body_txt)
        self.assert_In('<a name="api-specification"></a>\n# API Specification', body_txt)

    def test_autoanchor_false(self):
        body_txt = self.commonSetupAndUpdateGetBody(self.autoanchor_text.format('autoanchor=false'))
        self.assert_NotIn('<a name="changelog"></a>', body_txt)
        self.assert_NotIn('<a name="glossary"></a>', body_txt)
        self.assert_NotIn('<a name="api-specification"></a>', body_txt)


    # -----------------<commit_msg>cleanup: remove empty lines<commit_after># coding:utf-8
from base import TestBase

class TestAttribute(TestBase):
    """Test of attributes"""

    # for debug
    # def tearDown(self):
    #     pass

    # -----------------
    # Auto link

    autolink_text = \
"""

<!-- MarkdownTOC {0} -->

<!-- /MarkdownTOC -->

# Foo Bar
"""

    def test_autolink_default(self):
        """Default Auto link is false"""
        toc_txt = self.commonSetup(self.autolink_text.format(''))
        self.assert_In('- Foo Bar', toc_txt)

    def test_autolink_true(self):
        toc_txt = self.commonSetup(self.autolink_text.format('autolink=true'))
        self.assert_In('- [Foo Bar][foo-bar]', toc_txt)

    def test_autolink_false(self):
        toc_txt = self.commonSetup(self.autolink_text.format('autolink=false'))
        self.assert_In('- Foo Bar', toc_txt)


    # -----------------
    # Bracket

    # TODO: How can we remove "autolink=true" only in these tests below ?

    bracket_text = \
"""

<!-- MarkdownTOC autolink=true {0} -->

<!-- /MarkdownTOC -->

# foo bar
"""
    def test_bracket_default(self):
        """Default Bracket is square"""
        toc_txt = self.commonSetup(self.bracket_text.format(''))
        self.assert_In('- [foo bar][foo-bar]', toc_txt)

    def test_bracket_square(self):
        toc_txt = self.commonSetup(self.bracket_text.format('bracket=square'))
        self.assert_In('- [foo bar][foo-bar]', toc_txt)

    def test_bracket_round(self):
        toc_txt = self.commonSetup(self.bracket_text.format('bracket=round'))
        self.assert_In('- [foo bar](#foo-bar)', toc_txt)

    # -----------------
    # Depth

    depth_text = \
"""

<!-- MarkdownTOC {0} -->

<!-- /MarkdownTOC -->

# heading 1
## heading 2
### heading 3
#### heading 4
##### heading 5
"""
    def test_depth_default(self):
        """Default Depth is 2"""
        toc_txt = self.commonSetup(self.depth_text.format(''))
        self.assert_In('- heading 1', toc_txt)
        self.assert_In('- heading 2', toc_txt)
        self.assert_NotIn('- heading 3', toc_txt)
        self.assert_NotIn('- heading 4', toc_txt)
        self.assert_NotIn('- heading 5', toc_txt)

    def test_depth_0(self):
        """Depth 0 means no limit"""
        toc_txt = self.commonSetup(self.depth_text.format('depth=0'))
        self.assert_In('- heading 1', toc_txt)
        self.assert_In('- heading 2', toc_txt)
        self.assert_In('- heading 3', toc_txt)
        self.assert_In('- heading 4', toc_txt)
        self.assert_In('- heading 5', toc_txt)

    def test_depth_1(self):
        toc_txt = self.commonSetup(self.depth_text.format('depth=1'))
        self.assert_In('- heading 1', toc_txt)
        self.assert_NotIn('- heading 2', toc_txt)
        self.assert_NotIn('- heading 3', toc_txt)
        self.assert_NotIn('- heading 4', toc_txt)
        self.assert_NotIn('- heading 5', toc_txt)

    def test_depth_2(self):
        toc_txt = self.commonSetup(self.depth_text.format('depth=2'))
        self.assert_In('- heading 1', toc_txt)
        self.assert_In('- heading 2', toc_txt)
        self.assert_NotIn('- heading 3', toc_txt)
        self.assert_NotIn('- heading 4', toc_txt)
        self.assert_NotIn('- heading 5', toc_txt)

    def test_depth_3(self):
        toc_txt = self.commonSetup(self.depth_text.format('depth=3'))
        self.assert_In('- heading 1', toc_txt)
        self.assert_In('- heading 2', toc_txt)
        self.assert_In('- heading 3', toc_txt)
        self.assert_NotIn('- heading 4', toc_txt)
        self.assert_NotIn('- heading 5', toc_txt)

    def test_depth_4(self):
        toc_txt = self.commonSetup(self.depth_text.format('depth=4'))
        self.assert_In('- heading 1', toc_txt)
        self.assert_In('- heading 2', toc_txt)
        self.assert_In('- heading 3', toc_txt)
        self.assert_In('- heading 4', toc_txt)
        self.assert_NotIn('- heading 5', toc_txt)

    def test_depth_5(self):
        toc_txt = self.commonSetup(self.depth_text.format('depth=5'))
        self.assert_In('- heading 1', toc_txt)
        self.assert_In('- heading 2', toc_txt)
        self.assert_In('- heading 3', toc_txt)
        self.assert_In('- heading 4', toc_txt)
        self.assert_In('- heading 5', toc_txt)

    # -----------------
    # Auto anchor

    autoanchor_text = \
"""

<!-- MarkdownTOC autolink=true {0} -->

<!-- /MarkdownTOC -->

# Changelog
# Glossary
# API Specification
"""
    def get_body_text():
        pass

    def test_autoanchor_false(self):
        """Default Auto Anchor is false"""
        body_txt = self.commonSetupAndUpdateGetBody(self.autoanchor_text.format(''))
        self.assert_NotIn('<a name="changelog"></a>', body_txt)
        self.assert_NotIn('<a name="glossary"></a>', body_txt)
        self.assert_NotIn('<a name="api-specification"></a>', body_txt)

    def test_autoanchor_true(self):
        body_txt = self.commonSetupAndUpdateGetBody(self.autoanchor_text.format('autoanchor=true'))
        self.assert_In('<a name="changelog"></a>\n# Changelog', body_txt)
        self.assert_In('<a name="glossary"></a>\n# Glossary', body_txt)
        self.assert_In('<a name="api-specification"></a>\n# API Specification', body_txt)

    def test_autoanchor_false(self):
        body_txt = self.commonSetupAndUpdateGetBody(self.autoanchor_text.format('autoanchor=false'))
        self.assert_NotIn('<a name="changelog"></a>', body_txt)
        self.assert_NotIn('<a name="glossary"></a>', body_txt)
        self.assert_NotIn('<a name="api-specification"></a>', body_txt)


    # -----------------
{'fraction_non_alphanumeric': 0.1690660428288645, 'fraction_numerical': 0.010617239517725391, 'mean_word_length': 2.7626946513202437, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2938041', 'n_tokens_mistral': 3953, 'n_tokens_neox': 3770, 'n_words': 711}