Exemple #1
0
def test_prepare_renderer():
    configurator = Configurator(
        template='bobtemplates.plone:theme_barceloneta',
        target_directory='collective.foo',
        variables={
            'theme.name': 'test.theme',
        },
    )
    theme.prepare_renderer(configurator)

    assert configurator.variables['template_id'] == 'theme'
    assert configurator.variables['theme.normalized_name'] == 'test.theme'
Exemple #2
0
def test_prepare_renderer(tmpdir):
    base_path = tmpdir.strpath
    package_root_folder = os.path.join(
        base_path,
        'collective.foo',
    )
    configurator = Configurator(
        template='bobtemplates.plone:theme',
        target_directory=os.path.join(
            package_root_folder,
            'src/collective/foo',
        ),
        variables={
            'theme.name': 'test.theme',
            'package.root_folder': package_root_folder,
        },
    )
    init_package_base_files(configurator)
    theme.prepare_renderer(configurator)

    assert configurator.variables['template_id'] == 'theme'
    assert configurator.variables['theme.normalized_name'] == 'test.theme'
    assert configurator.target_directory.endswith(
        '/collective.foo/src/collective/foo')  # NOQA: E501

    # nested namespace package
    package_root_folder = os.path.join(
        base_path,
        'collective.foo.bar',
    )
    configurator = Configurator(
        template='bobtemplates.plone:theme',
        target_directory=os.path.join(
            package_root_folder,
            'src/collective/foo/bar',
        ),
        variables={
            'theme.name': 'test.theme',
            'package.root_folder': package_root_folder,
        },
    )
    init_package_base_files(configurator)
    theme.prepare_renderer(configurator)

    assert configurator.variables['template_id'] == 'theme'
    assert configurator.variables['theme.normalized_name'] == 'test.theme'
    assert configurator.target_directory.endswith(
        '/collective.foo.bar/src/collective/foo/bar')  # NOQA: E501
def test_post_renderer(tmpdir):
    package_root = tmpdir.strpath + "/collective.todo"
    package_path = init_package_base_structure(package_root)

    configurator = Configurator(
        template="bobtemplates.plone:theme",
        target_directory=package_path,
        bobconfig={"non_interactive": True},
        variables={
            "plone.version": "5.1",
            "theme.name": "My Theme"
        },
    )

    assert configurator
    os.chdir(package_path)
    base.set_global_vars(configurator)
    theme.prepare_renderer(configurator)
    configurator.render()
    theme.post_renderer(configurator)
def test_prepare_renderer(tmpdir):
    package_root = tmpdir.strpath + "/collective.todo"
    package_path = init_package_base_structure(package_root)

    configurator = Configurator(
        template="bobtemplates.plone:theme",
        target_directory=package_path,
        variables={
            "theme.name": "test.theme",
        },
    )
    theme.prepare_renderer(configurator)

    assert configurator.variables['template_id'] == 'theme'
    assert configurator.variables['theme.normalized_name'] == 'test.theme'
    assert configurator.target_directory.endswith(
        '/collective.todo/src/collective/todo')  # NOQA: E501

    # nested namespace package
    package_root = os.path.join(
        tmpdir.strpath,
        'collective.foo.bar',
    )
    package_path = init_package_base_structure(package_root)
    configurator = Configurator(
        template='bobtemplates.plone:theme',
        target_directory=package_path,
        variables={
            'theme.name': 'test.theme',
            'package.root_folder': package_root,
        },
    )
    theme.prepare_renderer(configurator)

    assert configurator.variables['template_id'] == 'theme'
    assert configurator.variables['theme.normalized_name'] == 'test.theme'
    assert configurator.target_directory.endswith(
        '/collective.foo.bar/src/collective/foo/bar')  # NOQA: E501
Exemple #5
0
def test_post_renderer(tmpdir):
    target_path = tmpdir.strpath + '/collective.theme'
    package_path = target_path + '/src/collective/theme'
    profiles_path = package_path + '/profiles/default'
    os.makedirs(target_path)
    os.makedirs(package_path)
    os.makedirs(profiles_path)

    template = """<?xml version="1.0" encoding="UTF-8"?>
<metadata>
  <version>1000</version>
  <dependencies>

  </dependencies>
</metadata>
"""
    with open(os.path.join(profiles_path + '/metadata.xml'), 'w') as f:
        f.write(template)

    template = """
[main]
version=5.1
"""
    with open(os.path.join(target_path + '/bobtemplate.cfg'), 'w') as f:
        f.write(template)

    template = """
    dummy
    '-*- Extra requirements: -*-'
"""
    with open(os.path.join(target_path + '/setup.py'), 'w') as f:
        f.write(template)

    template = """
    <configure
    xmlns="http://namespaces.zope.org/zope"
    xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
    xmlns:i18n="http://namespaces.zope.org/i18n"
    xmlns:plone="http://namespaces.plone.org/plone">

    <!-- -*- extra stuff goes here -*- -->

    </configure>
"""
    with open(os.path.join(package_path + '/configure.zcml'), 'w') as f:
        f.write(template)
    configurator = Configurator(
        template='bobtemplates.plone:theme_barceloneta',
        target_directory=package_path,
        bobconfig={
            'non_interactive': True,
        },
        variables={
            'plone.version': '5.1',
            'theme.name': 'My Theme',
        },
    )

    assert configurator
    os.chdir(package_path)
    base.set_global_vars(configurator)
    theme.prepare_renderer(configurator)
    configurator.render()
    theme.post_renderer(configurator)