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)
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)
def test_module_processing_modules_with_multiple_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_b_1 = Module( yaml.safe_load(""" name: org.test.module.b version: 1.1 """), 'path', 'artifact_path') module_registry = ModuleRegistry() module_registry.add_module(module_a) module_registry.add_module(module_b) module_registry.add_module(module_b_1) 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 'org.test.module.b' module, using '1.1' default version" in caplog.text
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' })])