def test_get_pages(self, testdir_fixture, project_fixture): page_object.new_page_object(testdir_fixture['path'], project_fixture['name'], ['subdir1', 'subdir2'], 'test3', add_parents=True) page_object.new_page_object(testdir_fixture['path'], project_fixture['name'], ['subdir1'], 'test2', add_parents=True) page_object.new_page_object(testdir_fixture['path'], project_fixture['name'], [], 'test1', add_parents=True) pages = utils.get_pages(testdir_fixture['path'], project_fixture['name']) expected_result = { 'type': 'directory', 'name': 'pages', 'dot_path': '.', 'sub_elements': [ { 'type': 'directory', 'name': 'subdir1', 'dot_path': 'subdir1', 'sub_elements': [ { 'type': 'directory', 'name': 'subdir2', 'dot_path': 'subdir1.subdir2', 'sub_elements': [ { 'type': 'file', 'name': 'test3', 'dot_path': 'subdir1.subdir2.test3', 'sub_elements': [] } ] }, { 'type': 'file', 'name': 'test2', 'dot_path': 'subdir1.test2', 'sub_elements': [] } ] }, { 'type': 'file', 'name': 'test1', 'dot_path': 'test1', 'sub_elements': [] } ] } assert pages == expected_result
def test_get_pages(self, testdir_fixture, project_fixture): page_object.new_page_object(testdir_fixture['path'], project_fixture['name'], ['subdir1', 'subdir2'], 'test3', add_parents=True) page_object.new_page_object(testdir_fixture['path'], project_fixture['name'], ['subdir1'], 'test2', add_parents=True) page_object.new_page_object(testdir_fixture['path'], project_fixture['name'], [], 'test1', add_parents=True) pages = utils.get_pages(testdir_fixture['path'], project_fixture['name']) expected_result = { 'type': 'directory', 'name': 'pages', 'dot_path': '.', 'sub_elements': [{ 'type': 'directory', 'name': 'subdir1', 'dot_path': 'subdir1', 'sub_elements': [{ 'type': 'directory', 'name': 'subdir2', 'dot_path': 'subdir1.subdir2', 'sub_elements': [{ 'type': 'file', 'name': 'test3', 'dot_path': 'subdir1.subdir2.test3', 'sub_elements': [] }] }, { 'type': 'file', 'name': 'test2', 'dot_path': 'subdir1.test2', 'sub_elements': [] }] }, { 'type': 'file', 'name': 'test1', 'dot_path': 'test1', 'sub_elements': [] }] } assert pages == expected_result
def test_get_pages_no_pages(self, project_function): _, project = project_function.activate() pages = utils.get_pages(project) expected = { 'type': 'directory', 'name': 'pages', 'dot_path': '.', 'sub_elements': [] } assert pages == expected
def test_get_pages(self, project_class): testdir = project_class.testdir project = project_class.name page_object.new_page_object(testdir, project, ['subdir1', 'subdir2'], 'test3') page_object.new_page_object(testdir, project, ['subdir1'], 'test2') page_object.new_page_object(testdir, project, [], 'test1') pages = utils.get_pages(testdir, project) expected = { 'type': 'directory', 'name': 'pages', 'dot_path': '.', 'sub_elements': [{ 'type': 'directory', 'name': 'subdir1', 'dot_path': 'subdir1', 'sub_elements': [{ 'type': 'directory', 'name': 'subdir2', 'dot_path': 'subdir1.subdir2', 'sub_elements': [{ 'type': 'file', 'name': 'test3', 'dot_path': 'subdir1.subdir2.test3', 'sub_elements': [] }] }, { 'type': 'file', 'name': 'test2', 'dot_path': 'subdir1.test2', 'sub_elements': [] }] }, { 'type': 'file', 'name': 'test1', 'dot_path': 'test1', 'sub_elements': [] }] } assert pages == expected
def get_pages(): if request.method == 'POST': project = request.form['project'] pages = utils.get_pages(root_path, project) return json.dumps(pages)
def test_get_pages_no_pages(self, project_function): testdir = project_function['testdir'] project = project_function['name'] pages = utils.get_pages(testdir, project) expected = {'type': 'directory', 'name': 'pages', 'dot_path': '.', 'sub_elements': []} assert pages == expected