当前位置: 首页>>代码示例>>Python>>正文


Python XMLState.set_derived_from_image_uri方法代码示例

本文整理汇总了Python中kiwi.xml_state.XMLState.set_derived_from_image_uri方法的典型用法代码示例。如果您正苦于以下问题:Python XMLState.set_derived_from_image_uri方法的具体用法?Python XMLState.set_derived_from_image_uri怎么用?Python XMLState.set_derived_from_image_uri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kiwi.xml_state.XMLState的用法示例。


在下文中一共展示了XMLState.set_derived_from_image_uri方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_set_derived_from_image_uri

# 需要导入模块: from kiwi.xml_state import XMLState [as 别名]
# 或者: from kiwi.xml_state.XMLState import set_derived_from_image_uri [as 别名]
 def test_set_derived_from_image_uri(self):
     xml_data = self.description.load()
     state = XMLState(xml_data, ['derivedContainer'], 'docker')
     state.set_derived_from_image_uri('file:///new_uri')
     assert state.get_derived_from_image_uri().translate() == '/new_uri'
开发者ID:Conan-Kudo,项目名称:kiwi,代码行数:7,代码来源:xml_state_test.py

示例2: TestXMLState

# 需要导入模块: from kiwi.xml_state import XMLState [as 别名]
# 或者: from kiwi.xml_state.XMLState import set_derived_from_image_uri [as 别名]

#.........这里部分代码省略.........
            'labels': [
                '--config.label=somelabel=labelvalue',
                '--config.label=someotherlabel=anotherlabelvalue'
            ],
            'maintainer': ['--author=tux'],
            'entry_subcommand': [
                '--config.cmd=ls',
                '--config.cmd=-l'
            ],
            'container_name': 'container_name',
            'container_tag': 'container_tag',
            'additional_tags': ['current', 'foobar'],
            'workingdir': ['--config.workingdir=/root'],
            'environment': [
                '--config.env=PATH=/bin:/usr/bin:/home/user/bin',
                '--config.env=SOMEVAR=somevalue'
            ],
            'user': ['--config.user=root'],
            'volumes': [
                '--config.volume=/tmp',
                '--config.volume=/var/log'
            ],
            'entry_command': [
                '--config.entrypoint=/bin/bash',
                '--config.entrypoint=-x'
            ],
            'expose_ports': [
                '--config.exposedports=80',
                '--config.exposedports=8080'
            ]
        }
        xml_data = self.description.load()
        state = XMLState(xml_data, ['vmxFlavour'], 'docker')
        assert state.get_container_config() == expected_config

    def test_get_container_config_clear_commands(self):
        expected_config = {
            'maintainer': ['--author=tux'],
            'entry_subcommand': [
                '--clear=config.cmd'
            ],
            'container_name': 'container_name',
            'container_tag': 'container_tag',
            'workingdir': ['--config.workingdir=/root'],
            'user': ['--config.user=root'],
            'entry_command': [
                '--clear=config.entrypoint',
            ]
        }
        xml_data = self.description.load()
        state = XMLState(xml_data, ['derivedContainer'], 'docker')
        assert state.get_container_config() == expected_config

    def test_get_spare_part(self):
        assert self.state.get_build_type_spare_part_size() == 200

    def test_get_build_type_format_options(self):
        assert self.state.get_build_type_format_options() == {
            'super': 'man',
            'force_size': None
        }

    def test_get_derived_from_image_uri(self):
        xml_data = self.description.load()
        state = XMLState(xml_data, ['derivedContainer'], 'docker')
        assert state.get_derived_from_image_uri().uri == \
            'obs://project/repo/image#mytag'

    def test_set_derived_from_image_uri(self):
        xml_data = self.description.load()
        state = XMLState(xml_data, ['derivedContainer'], 'docker')
        state.set_derived_from_image_uri('file:///new_uri')
        assert state.get_derived_from_image_uri().translate() == '/new_uri'

    @patch('kiwi.logger.log.warning')
    def test_set_derived_from_image_uri_not_applied(self, mock_log_warn):
        self.state.set_derived_from_image_uri('file:///new_uri')
        assert mock_log_warn.called

    def test_is_xen_server(self):
        assert self.state.is_xen_server() is True

    def test_is_xen_guest_by_machine_setup(self):
        assert self.state.is_xen_guest() is True

    def test_is_xen_guest_by_firmware_setup(self):
        xml_data = self.description.load()
        state = XMLState(xml_data, ['ec2Flavour'], 'vmx')
        assert state.is_xen_guest() is True

    def test_get_initrd_system(self):
        xml_data = self.description.load()
        state = XMLState(xml_data, ['vmxFlavour'], 'vmx')
        assert state.get_initrd_system() == 'dracut'
        state = XMLState(xml_data, ['vmxFlavour'], 'iso')
        assert state.get_initrd_system() == 'dracut'
        state = XMLState(xml_data, ['vmxFlavour'], 'docker')
        assert state.get_initrd_system() is None
        state = XMLState(xml_data, [], 'oem')
        assert state.get_initrd_system() == 'kiwi'
开发者ID:Conan-Kudo,项目名称:kiwi,代码行数:104,代码来源:xml_state_test.py


注:本文中的kiwi.xml_state.XMLState.set_derived_from_image_uri方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。