Example #1
0
def test_find_all_markdown_in_shallow_repo(exists):
    "DocumentIndexer#find_all_markdown_files() in a folder with no child nodes"

    origin = '/foo/bar'
    maker = DocumentIndexer(origin)
    maker.node = Mock(path='/weeee')
    maker.node.relative.side_effect = lambda x: "relative[{0}]".format(x)

    markdown_node = Mock()
    markdown_node.dir.path = '/ccc/aaa'
    markdown_node.path = '/FFF/000'
    maker.node.grep.return_value = [markdown_node]
    files = list(maker.find_all_markdown_files())
    files.should.equal([{
        u'path': u'/ccc/aaa',
        u'type': u'tree',
        u'relative_path': u'relative[/ccc/aaa]'
    },
    {
        u'path': u'/FFF/000',
        u'type': u'blob',
        u'relative_path': u'relative[/FFF/000]'
    }
    ])

    repr(maker).should.equal('<markment.fs.DocumentIndexer(path=/weeee)>')
Example #2
0
def test_treemaker_finds_all_files():
    ("DocumentIndexer should find all the markdown files in a given directory")

    tm = DocumentIndexer(LOCAL_FILE('sandbox_simple'))

    files = list(tm.find_all_markdown_files())
    files.should.have.length_of(7)

    files.should.equal([
        {
            'path': LOCAL_FILE('sandbox_simple'),
            'relative_path': './',
            'type': 'tree',
        },
        {
            'path': LOCAL_FILE('sandbox_simple', 'index.md'),
            'relative_path': 'index.md',
            'type': 'blob',
        },
        {
            'path': LOCAL_FILE('sandbox_simple', 'docs'),
            'relative_path': 'docs',
            'type': 'tree',
        },
        {
            'path': LOCAL_FILE('sandbox_simple', 'docs', 'output.md'),
            'relative_path': 'docs/output.md',
            'type': 'blob',
        },
        {
            'path': LOCAL_FILE('sandbox_simple', 'docs', 'strings.md'),
            'relative_path': 'docs/strings.md',
            'type': 'blob',
        },
        {
            'path': LOCAL_FILE('sandbox_simple', 'docs', 'even', 'deeper'),
            'relative_path': 'docs/even/deeper',
            'type': 'tree',
        },
        {
            'path': LOCAL_FILE('sandbox_simple', 'docs', 'even', 'deeper', 'item.md'),
            'relative_path': 'docs/even/deeper/item.md',
            'type': 'blob',
        },
    ])
Example #3
0
def test_find_all_markdown_in_shallow_repo(exists):
    "DocumentIndexer#find_all_markdown_files() in a folder with no child nodes"

    origin = '/foo/bar'
    maker = DocumentIndexer(origin)
    maker.node = Mock(path='/weeee')
    maker.node.relative.side_effect = lambda x: "relative[{0}]".format(x)

    markdown_node = Mock()
    markdown_node.dir.path = '/ccc/aaa'
    markdown_node.path = '/FFF/000'
    maker.node.grep.return_value = [markdown_node]
    files = list(maker.find_all_markdown_files())
    files.should.equal([{
        u'path': u'/ccc/aaa',
        u'type': u'tree',
        u'relative_path': u'relative[/ccc/aaa]'
    }, {
        u'path': u'/FFF/000',
        u'type': u'blob',
        u'relative_path': u'relative[/FFF/000]'
    }])

    repr(maker).should.equal('<markment.fs.DocumentIndexer(path=/weeee)>')