Esempio n. 1
0
def test_module_processing_fail_when_module_not_found_for_specific_version():
    image = Image(
        yaml.safe_load("""
        from: foo
        name: test/foo
        version: 1.9
        """), 'foo')

    module_a = Module(
        yaml.safe_load("""
        name: org.test.module.a
        version: 1.0
        """), 'path', 'artifact_path')

    module_registry = ModuleRegistry()
    module_registry.add_module(module_a)

    resulting_install_list = OrderedDict()

    to_install_list = [Map({'name': 'org.test.module.a', 'version': '1.1'})]

    with pytest.raises(CekitError) as excinfo:
        image.process_install_list(image, to_install_list,
                                   resulting_install_list, module_registry)

    assert "Module 'org.test.module.a' with version '1.1' could not be found, available versions: 1.0" in str(
        excinfo.value)
Esempio n. 2
0
def test_module_processing_fail_when_no_modules_of_specified_name_can_be_found(
):
    image = Image(
        yaml.safe_load("""
        from: foo
        name: test/foo
        version: 1.9
        """), 'foo')

    module_a = Module(
        yaml.safe_load("""
        name: org.test.module.a
        version: 1.0
        """), 'path', 'artifact_path')

    module_registry = ModuleRegistry()
    module_registry.add_module(module_a)

    resulting_install_list = OrderedDict()

    to_install_list = [
        Map({
            'name': 'org.test.module.a',
            'version': '1.0'
        }),
        Map({'name': 'org.test.module.b'})
    ]

    with pytest.raises(CekitError) as excinfo:
        image.process_install_list(image, to_install_list,
                                   resulting_install_list, module_registry)

    assert "There are no modules with 'org.test.module.b' name available" in str(
        excinfo.value)
Esempio n. 3
0
def test_module_processing_modules_with_single_versions(caplog):
    caplog.set_level(logging.DEBUG, logger="cekit")

    image = Image(
        yaml.safe_load("""
        from: foo
        name: test/foo
        version: 1.9
        """), 'foo')

    module_a = Module(
        yaml.safe_load("""
        name: org.test.module.a
        version: 1.0
        """), 'path', 'artifact_path')

    module_b = Module(
        yaml.safe_load("""
        name: org.test.module.b
        version: 1.0
        """), 'path', 'artifact_path')

    module_registry = ModuleRegistry()
    module_registry.add_module(module_a)
    module_registry.add_module(module_b)

    resulting_install_list = OrderedDict()

    to_install_list = [
        Map({
            'name': 'org.test.module.a',
            'version': '1.0'
        }),
        Map({'name': 'org.test.module.b'})
    ]

    image.process_install_list(image, to_install_list, resulting_install_list,
                               module_registry)

    assert resulting_install_list == OrderedDict([('org.test.module.a', {
        'name': 'org.test.module.a',
        'version': '1.0'
    }), ('org.test.module.b', {
        'name': 'org.test.module.b'
    })])

    assert "Module version not specified for" not in caplog.text
Esempio n. 4
0
def test_module_processing_simple_modules_order_to_install():
    image = Image(
        yaml.safe_load("""
        from: foo
        name: test/foo
        version: 1.9
        """), 'foo')

    module_a = Module(
        yaml.safe_load("""
        name: org.test.module.a
        version: 1.0
        """), 'path', 'artifact_path')

    module_b = Module(
        yaml.safe_load("""
        name: org.test.module.b
        version: 1.0
        """), 'path', 'artifact_path')

    module_registry = ModuleRegistry()
    module_registry.add_module(module_a)
    module_registry.add_module(module_b)

    resulting_install_list = OrderedDict()

    to_install_list = [
        Map({
            'name': 'org.test.module.a',
            'version': '1.0'
        }),
        Map({'name': 'org.test.module.b'})
    ]

    image.process_install_list(image, to_install_list, resulting_install_list,
                               module_registry)

    assert resulting_install_list == OrderedDict([('org.test.module.a', {
        'name': 'org.test.module.a',
        'version': '1.0'
    }), ('org.test.module.b', {
        'name': 'org.test.module.b'
    })])
Esempio n. 5
0
def test_module_processing_warning_when_a_module_version_cannot_be_parsed_as_pep_440(
        caplog):
    caplog.set_level(logging.DEBUG, logger="cekit")

    module_a = Module(
        yaml.safe_load("""
        name: org.test.module.a
        version: 1.0
        """), 'path', 'artifact_path')

    module_a1 = Module(
        yaml.safe_load("""
        name: org.test.module.a
        version: aa fs df
        """), 'path', 'artifact_path')

    module_registry = ModuleRegistry()
    module_registry.add_module(module_a)
    module_registry.add_module(module_a1)

    assert "Module's 'org.test.module.a' version 'aa fs df' does not follow PEP 440 versioning scheme (https://www.python.org/dev/peps/pep-0440), we suggest follow this versioning scheme in modules" in caplog.text
Esempio n. 6
0
def test_module_processing_fail_when_a_module_aready_exists_in_registry():
    module_a = Module(
        yaml.safe_load("""
        name: org.test.module.a
        version: 1.0
        """), 'path', 'artifact_path')

    module_a1 = Module(
        yaml.safe_load("""
        name: org.test.module.a
        version: 1.0
        """), 'path', 'artifact_path')

    module_registry = ModuleRegistry()
    module_registry.add_module(module_a)

    with pytest.raises(CekitError) as excinfo:
        module_registry.add_module(module_a1)

    assert "Module 'org.test.module.a' with version '1.0' already exists in module registry" in str(
        excinfo.value)