예제 #1
0
    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
예제 #2
0
    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
예제 #3
0
 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
예제 #4
0
 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
예제 #5
0
def get_pages():
    if request.method == 'POST':
        project = request.form['project']
        pages = utils.get_pages(root_path, project)
        return json.dumps(pages)
예제 #6
0
def get_pages():
    if request.method == 'POST':
        project = request.form['project']
        pages = utils.get_pages(root_path, project)
        return json.dumps(pages)
예제 #7
0
 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