Пример #1
0
def test_parse_front_matter_handles_no_fm():

    # 'file' lines without front matter
    lines = ['These\n', 'are\n', '---\n', 'some\n', 'lines\n']

    search_mode = SearchMode()
    res = search_mode._parse_frontmatter(lines)

    assert res == {}
    assert len(res) == 0
Пример #2
0
def test_parse_front_matter_handles_no_ending_dashses():
    """If the front matter is not ended correctly (`---`)"""

    lines = [
        '---\n',
        'actual: fm\n',
        '# Heading 1\n',
        'paragraph 1\n',
        '## Heading 2\n',
    ]

    search_mode = SearchMode()
    res = search_mode._parse_frontmatter(lines)
    assert res == {'actual': 'fm'}
Пример #3
0
def test_parse_front_matter_parses_correct_data(lines, result):

    search_mode = SearchMode()
    res = search_mode._parse_frontmatter(lines)
    assert res == result