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


Python NuleculeComponent.render_artifact方法代码示例

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


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

示例1: test_render_artifact

# 需要导入模块: from atomicapp.nulecule.base import NuleculeComponent [as 别名]
# 或者: from atomicapp.nulecule.base.NuleculeComponent import render_artifact [as 别名]
    def test_render_artifact(self, mock_open):
        source_content = 'some text: $key1'
        expected_rendered_content = 'some text: val1'
        context = {'key1': 'val1'}

        # Mock context for opening file.
        mock_open_source_file_context = mock.MagicMock(
            name='source_artifact_context')
        mock_open_target_file_context = mock.MagicMock(
            name='target_artifact_context')

        # Mock file objects
        mock_source_file = mock_open_source_file_context.__enter__()
        mock_target_file = mock_open_target_file_context.__enter__()
        mock_source_file.read.return_value = source_content

        def mock_open_resp(path, mode):
            if path == 'some/path/artifact':
                return mock_open_source_file_context
            elif path == 'some/path/.artifact':
                return mock_open_target_file_context

        mock_open.side_effect = mock_open_resp

        nc = NuleculeComponent(name='some-name', basepath='some/path')
        nc.artifacts = {'some-provider': [{}]}

        self.assertEqual(
            nc.render_artifact('some/path/artifact', context, 'some-provider'),
            '.artifact')
        mock_source_file.read.assert_called_once_with()
        mock_target_file.write.assert_called_once_with(
            expected_rendered_content)
开发者ID:surajssd,项目名称:atomicapp,代码行数:35,代码来源:test_nulecule_component.py


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