Ejemplo n.º 1
0
def test_config_nodes_absence(empty_config_file):
    with open(empty_config_file, "r") as main_file:
        parser = ConfigurationParser(main_file)
        assert not parser.has_bootstrap_node()
        with pytest.raises(FatalError) as error:
            parser.get_bootstrap_repository()
        assert "repository" in error.value.message
        with pytest.raises(FatalError) as error:
            parser.get_bootstrap_architecture()
        assert "architecture" in error.value.message
Ejemplo n.º 2
0
def test_configuration_rendering(tmpdir):
    source = os.path.join(get_edi_plugin_directory(), 'config_templates',
                          'project_tree')
    assert os.path.isdir(source)
    assert not os.listdir(str(tmpdir))  # target should be empty

    copy_tree(source, str(tmpdir))
    template_link = os.path.join(str(tmpdir),
                                 'PROJECTNAME-develop.yml.edilink')
    assert os.path.isfile(template_link)

    template = ConfigurationTemplate(str(tmpdir))
    result = template.render({'edi_project_name': 'test-project'})
    assert 'PROJECTNAME' not in ''.join(result)
    assert 'plugins/playbooks/sample_playbook/roles/sample_role/tasks/main.yml' in ''.join(
        result)

    assert not os.path.isfile(template_link)

    test_project_dev = os.path.join(str(tmpdir), 'test-project-develop.yml')
    assert os.path.isfile(test_project_dev)
    assert os.path.islink(test_project_dev)
    gitignore = os.path.join(str(tmpdir), '.gitignore')
    assert os.path.isfile(gitignore)

    with open(test_project_dev, mode='r', encoding='UTF-8') as config_file:
        cp = ConfigurationParser(config_file)
        assert cp.get_bootstrap_architecture() == 'amd64'
Ejemplo n.º 3
0
def test_bootstrap_overlay(config_files):
    with open(config_files, "r") as main_file:
        parser = ConfigurationParser(main_file)
        # the host file shall win
        boostrap_source = SourceEntry(parser.get_bootstrap_repository())
        assert parser.get_bootstrap_architecture() == "i386"
        assert "main" in boostrap_source.comps
        assert boostrap_source.uri == "http://deb.debian.org/debian/"
        # the all file shall provide this key
        expected_key = "https://ftp-master.debian.org/keys/archive-key-8.asc"
        assert parser.get_bootstrap_repository_key() == expected_key
        assert boostrap_source.dist == "jessie"
        assert parser.get_bootstrap_tool() == "debootstrap"
Ejemplo n.º 4
0
def test_config_nodes_presence(config_files):
    with open(config_files, "r") as main_file:
        parser = ConfigurationParser(main_file)
        assert parser.has_bootstrap_node()
        assert parser.get_bootstrap_repository()
        assert parser.get_bootstrap_architecture()