Beispiel #1
0
def test_is_correct_type():
    config = {
        'name': 'folder',
        'target_name': 'folder',
        'type': 'folder',
    }
    folder = FolderNode(config, 'folder', 'folder')

    config = {
        'name': 'page',
        'target_name': 'page.html',
        'url': 'page',
    }
    page = JinjaNode(config, get_test_file('a_folder/page.j2'), '')

    config = {
        'name': 'asset',
        'target_name': 'asset.xml',
        'url': 'asset'
    }
    asset = AssetNode(config, get_test_file('a_folder/a_file.txt'), '')

    assert folder.is_folder == True
    assert folder.is_page == False
    assert folder.is_asset == False

    assert page.is_folder == False
    assert page.is_page == True
    assert page.is_asset == False

    assert asset.is_folder == False
    assert asset.is_page == False
    assert asset.is_asset == True
Beispiel #2
0
def test_url():
    config = {
        'root_url': '/',
    }
    root = RootFolderNode(config, '', '')

    config = {
        'name': 'parent',
        'target_name': 'parent',
    }
    parent = FolderNode(config, 'parent', 'parent')
    root.append(parent)

    config = {
        'name': 'bob',
        'target_name': 'bob.html',
    }
    bob = JinjaNode(config, get_test_file('a_folder/page.j2'), '')

    config = {
        'name': 'jane',
        'target_name': 'jane.html',
    }
    jane = JinjaNode(config, get_test_file('a_folder/page.j2'), '')

    parent.extend([bob, jane])

    assert bob.url == '/parent/bob.html'
    assert jane.url == '/parent/jane.html'
Beispiel #3
0
def test_url_override():
    config = {
        'root_url': '/foo/',
    }
    root = RootFolderNode(config, '', '')

    config = {
        'name': 'parent',
        'target_name': 'parent',
        'type': 'folder',
    }
    parent = FolderNode(config, 'parent', 'parent')
    root.append(parent)

    config = {
        'name': 'bob',
        'target_name': 'bob.html',
        'url': 'bob',
    }
    bob = JinjaNode(config, get_test_file('a_folder/page.j2'), '')

    config = {
        'name': 'jane',
        'target_name': 'jane.xml',
        'url': 'jane'
    }
    jane = AssetNode(config, get_test_file('a_folder/a_file.txt'), '')

    parent.extend([bob, jane])

    assert bob.url == '/foo/parent/bob'
    assert jane.url == '/foo/parent/jane'
Beispiel #4
0
def test_is_correct_type():
    config = {
        'name': 'folder',
        'target_name': 'folder',
        'type': 'folder',
    }
    folder = FolderNode(config, 'folder', 'folder')

    config = {
        'name': 'page',
        'target_name': 'page.html',
        'url': 'page',
    }
    page = JinjaNode(config, get_test_file('a_folder/page.j2'), '')

    config = {'name': 'asset', 'target_name': 'asset.xml', 'url': 'asset'}
    asset = AssetNode(config, get_test_file('a_folder/a_file.txt'), '')

    assert folder.is_folder == True
    assert folder.is_page == False
    assert folder.is_asset == False

    assert page.is_folder == False
    assert page.is_page == True
    assert page.is_asset == False

    assert asset.is_folder == False
    assert asset.is_page == False
    assert asset.is_asset == True
Beispiel #5
0
def test_url():
    config = {
        'root_url': '/',
        'iterable': True,
    }
    root = RootFolderNode(config, '', '')

    config = {
        'name': 'parent',
        'target_name': 'parent',
        'iterable': True,
    }
    parent = FolderNode(config, 'parent', 'parent')
    root.append(parent)

    config = {
        'name': 'bob',
        'target_name': 'bob.html',
        'iterable': True,
    }
    bob = JinjaNode(config, get_test_file('a_folder/page.j2'), '')

    config = {
        'name': 'jane',
        'target_name': 'jane.html',
        'iterable': True,
    }
    jane = JinjaNode(config, get_test_file('a_folder/page.j2'), '')

    parent.extend([bob, jane])

    assert bob.url == '/parent/bob.html'
    assert jane.url == '/parent/jane.html'
Beispiel #6
0
def test_url_override():
    config = {
        'root_url': '/foo/',
    }
    root = RootFolderNode(config, '', '')

    config = {
        'name': 'parent',
        'target_name': 'parent',
        'type': 'folder',
    }
    parent = FolderNode(config, 'parent', 'parent')
    root.append(parent)

    config = {
        'name': 'bob',
        'target_name': 'bob.html',
        'url': 'bob',
    }
    bob = JinjaNode(config, get_test_file('a_folder/page.j2'), '')

    config = {'name': 'jane', 'target_name': 'jane.xml', 'url': 'jane'}
    jane = AssetNode(config, get_test_file('a_folder/a_file.txt'), '')

    parent.extend([bob, jane])

    assert bob.url == '/foo/parent/bob'
    assert jane.url == '/foo/parent/jane'
Beispiel #7
0
 def __init__(self, name):
     config = {
         'target_name': name,
         'name': name,
         'iterable': True,
     }
     super(TestPageNode, self).__init__(config=config,
                               source_path=get_test_file('a_folder/a_file.txt'),
                               target_folder='target')
Beispiel #8
0
 def __init__(self, name):
     config = {
         'url': '',
         'target_name': name,
         'name': name,
         'iterable': False,
     }
     super(TestIndexNode, self).__init__(config=config,
                               source_path=get_test_file('a_folder/a_file.txt'),
                               target_folder='target')
Beispiel #9
0
 def __init__(self, name='test', addl_config={}):
     config = {
         'target_name': name,
         'name': name,
         'url': name,
         'iterable': True,
     }
     config.update(addl_config)
     super(TestFolderNode, self).__init__(config=config,
                               source_path=get_test_file('a_folder/'),
                               target_folder='target')
Beispiel #10
0
 def __init__(self, name, addl_config={}):
     config = {
         'target_name': name,
         'name': name,
         'url': '',
         'iterable': False,
         'is_index': True,
     }
     config.update(addl_config)
     super(TestIndexNode, self).__init__(config=config,
                               source_path=get_test_file('a_folder/a_file.txt'),
                               target_folder='target')
Beispiel #11
0
 def __init__(self, name='test', addl_config={}):
     config = {
         'target_name': name,
         'name': name,
         'iterable': True,
         'root_url': '/',
     }
     config.update(addl_config)
     Registry.set('root', self)
     super(TestRootNode, self).__init__(config=config,
                               source_path=get_test_file('a_folder/'),
                               target_folder='target')
Beispiel #12
0
 def __init__(self, name, addl_config={}):
     config = {
         'target_name': name,
         'name': name,
         'url': name,
         'iterable': True,
     }
     config.update(addl_config)
     super(MockingPageNode,
           self).__init__(config=config,
                          source_path=get_test_file('a_folder/a_file.txt'),
                          target_folder='target')
Beispiel #13
0
 def __init__(self, name='test', addl_config={}):
     config = {
         'target_name': name,
         'name': name,
         'iterable': True,
         'root_url': '/',
     }
     config.update(addl_config)
     Registry.set('root', self)
     super(MockingRootNode,
           self).__init__(config=config,
                          source_path=get_test_file('a_folder/'),
                          target_folder='target')
Beispiel #14
0
def test_is_correct_type_reversed_override():
    config = {
        'name': 'page',
        'target_name': 'page.html',
        'url': 'page',
        'is_asset': True,
    }
    page = JinjaNode(config, get_test_file('a_folder/page.j2'), '')

    config = {
        'name': 'asset',
        'target_name': 'asset.xml',
        'url': 'asset',
        'is_page': True,
    }
    asset = AssetNode(config, get_test_file('a_folder/a_file.txt'), '')

    assert page.is_folder == False
    assert page.is_page == False
    assert page.is_asset == True

    assert asset.is_folder == False
    assert asset.is_page == True
    assert asset.is_asset == False
Beispiel #15
0
def test_is_correct_type_reversed_override():
    config = {
        'name': 'page',
        'target_name': 'page.html',
        'url': 'page',
        'is_asset': True,
    }
    page = JinjaNode(config, get_test_file('a_folder/page.j2'), '')

    config = {
        'name': 'asset',
        'target_name': 'asset.xml',
        'url': 'asset',
        'is_page': True,
    }
    asset = AssetNode(config, get_test_file('a_folder/a_file.txt'), '')

    assert page.is_folder == False
    assert page.is_page == False
    assert page.is_asset == True

    assert asset.is_folder == False
    assert asset.is_page == True
    assert asset.is_asset == False