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


Python NuleculeComponent.artifacts方法代码示例

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


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

示例1: test_render_artifact

# 需要导入模块: from atomicapp.nulecule.base import NuleculeComponent [as 别名]
# 或者: from atomicapp.nulecule.base.NuleculeComponent import artifacts [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

示例2: test_render_for_local_app_with_artifacts_for_provider

# 需要导入模块: from atomicapp.nulecule.base import NuleculeComponent [as 别名]
# 或者: from atomicapp.nulecule.base.NuleculeComponent import artifacts [as 别名]
    def test_render_for_local_app_with_artifacts_for_provider(
            self, mock_render_artifact, mock_get_artifact_paths_for_provider,
            mock_get_context):
        """Test rendering artifacts for a local Nulecule component"""
        provider_key = 'some-provider'
        dryrun = False
        expected_rendered_artifacts = [
            'some/path/.artifact1', 'some/path/.artifact2']
        context = {'a': 'b'}
        mock_get_artifact_paths_for_provider.return_value = [
            'some/path/artifact1', 'some/path/artifact2']
        mock_render_artifact.side_effect = lambda path, context, provider: path.replace('artifact', '.artifact')
        mock_get_context.return_value = context

        nc = NuleculeComponent(name='some-app', basepath='some/path')
        nc.config = {'general': {'key1': 'val1'}, 'some-provider': {'a': 'b'}}
        nc.artifacts = {
            'some-provider': ['artifact1', 'artifact2'],
            'x': ['foo']
        }
        nc.render(provider_key, dryrun)

        mock_get_artifact_paths_for_provider.assert_called_once_with(
            provider_key)
        mock_render_artifact.assert_any_call('some/path/artifact1', context,
                                             'some-provider')
        mock_render_artifact.assert_any_call('some/path/artifact2', context,
                                             'some-provider')
        mock_get_artifact_paths_for_provider.assert_called_once_with(
            provider_key)
        self.assertEqual(nc.rendered_artifacts[provider_key],
                         expected_rendered_artifacts)
开发者ID:surajssd,项目名称:atomicapp,代码行数:34,代码来源:test_nulecule_component.py

示例3: test_artifact_paths_for_provider

# 需要导入模块: from atomicapp.nulecule.base import NuleculeComponent [as 别名]
# 或者: from atomicapp.nulecule.base.NuleculeComponent import artifacts [as 别名]
    def test_artifact_paths_for_provider(
            self, mock_get_artifact_paths_for_path):
        provider_key = 'some-provider'
        expected_artifact_paths = [
            'some/path/relative/path/to/artifact1',
            '/abs/path/to/artifact2',
            'some/path/x/artifact3'
        ]
        mock_get_artifact_paths_for_path.side_effect = lambda path: [path]

        nc = NuleculeComponent(name='some-app', basepath='some/path')
        nc.artifacts = {
            provider_key: [
                'file://relative/path/to/artifact1',
                'file:///abs/path/to/artifact2',
                {
                    'inherit': ['x-provider']
                }
            ],
            'x-provider': [
                'file://x/artifact3'
            ]
        }

        self.assertEqual(nc.get_artifact_paths_for_provider(provider_key),
                         expected_artifact_paths)
开发者ID:surajssd,项目名称:atomicapp,代码行数:28,代码来源:test_nulecule_component.py

示例4: test_render_for_local_app_with_missing_artifacts_for_provider

# 需要导入模块: from atomicapp.nulecule.base import NuleculeComponent [as 别名]
# 或者: from atomicapp.nulecule.base.NuleculeComponent import artifacts [as 别名]
    def test_render_for_local_app_with_missing_artifacts_for_provider(self):
        """
        Test rendering a Nulecule component with missing artifacts for a
        provider.
        """
        provider_key = 'some-provider'
        dryrun = False

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

        self.assertRaises(NuleculeException, nc.render, provider_key, dryrun)
开发者ID:surajssd,项目名称:atomicapp,代码行数:15,代码来源:test_nulecule_component.py


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