예제 #1
0
    def test_two_nested_dirs_one_file(self):
        mkdir(os.path.join(self.root, 'foo'))
        mkdir(os.path.join(self.root, 'foo', 'bar'))
        mkfile(os.path.join(self.root, 'foo', 'bar', 'spam'))

        expected = {
            'data': ROOT_NAME,
            'attr': {'href': '/'},
            'children': [
                {
                    'data': 'foo',
                    'attr': {'href': '/foo'},
                    'children': [
                        {
                            'data': 'bar',
                            'attr': {'href': '/foo/bar'},
                            'children': [
                                {
                                    'data': 'spam',
                                    'attr': {'href': '/foo/bar/spam'},
                                }
                            ],
                        },
                    ]
                }
            ],
        }

        result = jstree.generate_tree(self.root)

        self.assertEquals(result, expected)
예제 #2
0
    def test_empty_directory(self):
        expected = {
            'data': ROOT_NAME,
            'attr': {'href': '/'},
            'children': [],
        }

        result = jstree.generate_tree(self.root)

        self.assertEquals(result, expected)
예제 #3
0
    def test_one_file(self):
        mkfile(os.path.join(self.root, 'foo'))

        expected = {
            'data': ROOT_NAME,
            'attr': {'href': '/'},
            'children': [{
                'data': 'foo',
                'attr': {'href': '/foo'},
            }],
        }

        result = jstree.generate_tree(self.root)

        self.assertEquals(result, expected)
예제 #4
0
파일: views.py 프로젝트: duthils/greglink
def jstree():
    tree = generate_tree(app.config['TEST_ROOT'])
    return (json.dumps(tree), 200)