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


Python Nulecule.load_components方法代码示例

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


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

示例1: test_load_components

# 需要导入模块: from atomicapp.nulecule.base import Nulecule [as 别名]
# 或者: from atomicapp.nulecule.base.Nulecule import load_components [as 别名]
    def test_load_components(self, MockNuleculeComponent):
        graph = [
            {
                'name': 'app1',
                'source': 'docker://somecontainer',
                'params': []
            },
            {
                'name': 'app2',
                'artifacts': [
                    {'a': 'b'}
                ]
            }
        ]

        config = Config(answers={})

        n = Nulecule('some-id', '0.0.2', graph, 'some/path', config=config)
        n.load_components()

        MockNuleculeComponent.assert_any_call(
            graph[0]['name'], n.basepath, 'somecontainer',
            graph[0]['params'], None, config)
        MockNuleculeComponent.assert_any_call(
            graph[1]['name'], n.basepath, None,
            graph[1].get('params'), graph[1].get('artifacts'), config)
开发者ID:LalatenduMohanty,项目名称:atomicapp,代码行数:28,代码来源:test_nulecule.py

示例2: test_load_config_without_default_provider

# 需要导入模块: from atomicapp.nulecule.base import Nulecule [as 别名]
# 或者: from atomicapp.nulecule.base.Nulecule import load_components [as 别名]
    def test_load_config_without_default_provider(self):
        """
        Test Nulecule load_config without specifying a default provider.
        """
        config = Config()

        params = [
            {
                "name": "key1",
                "default": "val1",
            },
            {
                "name": "key3",
                "default": "val3"
            }
        ]

        graph = [
            {
                "name": "component1",
                "params": [
                    {
                        "name": "key1",
                    },
                    {
                        "name": "key2",
                        "default": "val2"
                    }
                ],
                "artifacts": []
            }
        ]

        n = Nulecule(id='some-id', specversion='0.0.2', metadata={},
                     graph=graph, params=params, basepath='some/path',
                     config=config)
        n.load_components()
        n.load_config()

        self.assertEqual(n.config.runtime_answers(), {
            'general': {
                'namespace': 'default',
                'provider': 'kubernetes',
                'key1': 'val1',
                'key3': 'val3'
            },
            'component1': {
                'key2': 'val2'
            }
        })

        self.assertEqual(
            n.components[0].config.context(n.components[0].namespace),
            {'key3': 'val3',
             'key2': 'val2',
             'key1': 'val1',
             'namespace': 'default',
             'provider': 'kubernetes'}
        )
开发者ID:LalatenduMohanty,项目名称:atomicapp,代码行数:61,代码来源:test_nulecule.py

示例3: test_load_components

# 需要导入模块: from atomicapp.nulecule.base import Nulecule [as 别名]
# 或者: from atomicapp.nulecule.base.Nulecule import load_components [as 别名]
    def test_load_components(self, MockNuleculeComponent):
        graph = [
            {"name": "app1", "source": "docker://somecontainer", "params": []},
            {"name": "app2", "artifacts": [{"a": "b"}]},
        ]

        n = Nulecule("some-id", "0.0.2", graph, "some/path", {})
        n.load_components()

        MockNuleculeComponent.assert_any_call(
            graph[0]["name"], n.basepath, "somecontainer", graph[0]["params"], None, {}
        )
        MockNuleculeComponent.assert_any_call(
            graph[1]["name"], n.basepath, None, graph[1].get("params"), graph[1].get("artifacts"), {}
        )
开发者ID:Ritsyy,项目名称:atomicapp,代码行数:17,代码来源:test_nulecule.py

示例4: test_load_config_with_default_provider_overridden_by_answers

# 需要导入模块: from atomicapp.nulecule.base import Nulecule [as 别名]
# 或者: from atomicapp.nulecule.base.Nulecule import load_components [as 别名]
    def test_load_config_with_default_provider_overridden_by_answers(self):
        """
        Test Nulecule load_config with default provider overridden by provider
        in answers.
        """
        config = Config(answers={
            'general': {
                'provider': 'openshift'
            }
        })

        params = [
            {
                "name": "key1",
                "default": "val1",
            },
            {
                "name": "key3",
                "default": "val3"
            },
            {
                "name": "provider",
                "default": "docker"
            }
        ]

        graph = [
            {
                "name": "component1",
                "params": [
                    {
                        "name": "key1",
                    },
                    {
                        "name": "key2",
                        "default": "val2"
                    }
                ],
                "artifacts": []
            }
        ]

        n = Nulecule(id='some-id', specversion='0.0.2', metadata={},
                     graph=graph, params=params, basepath='some/path',
                     config=config)
        n.load_components()
        n.load_config(config)

        self.assertEqual(n.config.runtime_answers(), {
            'general': {
                'namespace': 'default',
                'provider': 'openshift',
                'key1': 'val1',
                'key3': 'val3'
            },
            'component1': {
                'key2': 'val2'
            }
        })

        self.assertEqual(
            n.components[0].config.context(n.components[0].namespace),
            {'key3': 'val3',
             'key2': 'val2',
             'key1': 'val1',
             'namespace': 'default',
             'provider': 'openshift'}
        )
开发者ID:LalatenduMohanty,项目名称:atomicapp,代码行数:70,代码来源:test_nulecule.py


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