當前位置: 首頁>>代碼示例>>Python>>正文


Python Nulecule.load_config方法代碼示例

本文整理匯總了Python中atomicapp.nulecule.base.Nulecule.load_config方法的典型用法代碼示例。如果您正苦於以下問題:Python Nulecule.load_config方法的具體用法?Python Nulecule.load_config怎麽用?Python Nulecule.load_config使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在atomicapp.nulecule.base.Nulecule的用法示例。


在下文中一共展示了Nulecule.load_config方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_load_config_without_default_provider

# 需要導入模塊: from atomicapp.nulecule.base import Nulecule [as 別名]
# 或者: from atomicapp.nulecule.base.Nulecule import load_config [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

示例2: test_load_config_without_specified_provider

# 需要導入模塊: from atomicapp.nulecule.base import Nulecule [as 別名]
# 或者: from atomicapp.nulecule.base.Nulecule import load_config [as 別名]
    def test_load_config_without_specified_provider(self):
        """
        Test Nulecule load_config without specifying a provider.
        """
        config = {"general": {}, "group1": {"a": "b"}}
        mock_component_1 = mock.Mock()
        mock_component_1.config = {"group1": {"a": "c", "k": "v"}, "group2": {"1": "2"}}

        n = Nulecule(id="some-id", specversion="0.0.2", metadata={}, graph=[], basepath="some/path")
        n.components = [mock_component_1]
        n.load_config(config)

        self.assertEqual(
            n.config, {"general": {"provider": "kubernetes"}, "group1": {"a": "b", "k": "v"}, "group2": {"1": "2"}}
        )
開發者ID:Ritsyy,項目名稱:atomicapp,代碼行數:17,代碼來源:test_nulecule.py

示例3: test_load_config

# 需要導入模塊: from atomicapp.nulecule.base import Nulecule [as 別名]
# 或者: from atomicapp.nulecule.base.Nulecule import load_config [as 別名]
    def test_load_config(self):
        config = {'group1': {'a': 'b'}}
        mock_component_1 = mock.Mock()
        mock_component_1.config = {
            'group1': {'a': 'c', 'k': 'v'},
            'group2': {'1': '2'}
        }

        n = Nulecule('some-id', '0.0.2', {}, [], 'some/path')
        n.components = [mock_component_1]
        n.load_config(config)

        self.assertEqual(n.config, {
            'group1': {'a': 'b', 'k': 'v'},
            'group2': {'1': '2'}
        })
開發者ID:schmerk,項目名稱:atomicapp,代碼行數:18,代碼來源:test_nulecule.py

示例4: test_load_config_without_specified_provider

# 需要導入模塊: from atomicapp.nulecule.base import Nulecule [as 別名]
# 或者: from atomicapp.nulecule.base.Nulecule import load_config [as 別名]
    def test_load_config_without_specified_provider(self):
        """
        Test Nulecule load_config without specifying a provider.
        """
        config = {'general': {}, 'group1': {'a': 'b'}}
        mock_component_1 = mock.Mock()
        mock_component_1.config = {
            'group1': {'a': 'c', 'k': 'v'},
            'group2': {'1': '2'}
        }

        n = Nulecule(id='some-id', specversion='0.0.2', metadata={}, graph=[], basepath='some/path')
        n.components = [mock_component_1]
        n.load_config(config)

        self.assertEqual(n.config, {
            'general': {'provider': 'kubernetes'},
            'group1': {'a': 'b', 'k': 'v'},
            'group2': {'1': '2'}
        })
開發者ID:surajssd,項目名稱:atomicapp,代碼行數:22,代碼來源:test_nulecule.py

示例5: test_load_config_with_defaultprovider_overridden_by_provider_in_answers

# 需要導入模塊: from atomicapp.nulecule.base import Nulecule [as 別名]
# 或者: from atomicapp.nulecule.base.Nulecule import load_config [as 別名]
    def test_load_config_with_defaultprovider_overridden_by_provider_in_answers(self):
        """
        Test Nulecule load_config with default provider specified
        in global params in Nulecule spec, but overridden in answers config.
        """
        config = {"general": {"provider": "new-provider"}, "group1": {"a": "b"}}
        mock_component_1 = mock.Mock()
        mock_component_1.config = {"group1": {"a": "c", "k": "v"}, "group2": {"1": "2"}}

        n = Nulecule(
            id="some-id",
            specversion="0.0.2",
            metadata={},
            graph=[],
            basepath="some/path",
            params=[{"name": "provider", "default": "some-provider"}],
        )
        n.components = [mock_component_1]
        n.load_config(config)

        self.assertEqual(
            n.config, {"general": {"provider": "new-provider"}, "group1": {"a": "b", "k": "v"}, "group2": {"1": "2"}}
        )
開發者ID:Ritsyy,項目名稱:atomicapp,代碼行數:25,代碼來源:test_nulecule.py

示例6: test_load_config_with_defaultprovider

# 需要導入模塊: from atomicapp.nulecule.base import Nulecule [as 別名]
# 或者: from atomicapp.nulecule.base.Nulecule import load_config [as 別名]
    def test_load_config_with_defaultprovider(self):
        """
        Test Nulecule load_config with default provider specified
        in global params in Nulecule spec.
        """
        config = {'general': {}, 'group1': {'a': 'b'}}
        mock_component_1 = mock.Mock()
        mock_component_1.config = {
            'group1': {'a': 'c', 'k': 'v'},
            'group2': {'1': '2'}
        }

        n = Nulecule(id='some-id', specversion='0.0.2', metadata={}, graph=[],
                     basepath='some/path',
                     params=[{'name': 'provider', 'default': 'some-provider'}])
        n.components = [mock_component_1]
        n.load_config(config)

        self.assertEqual(n.config, {
            'general': {'provider': 'some-provider'},
            'group1': {'a': 'b', 'k': 'v'},
            'group2': {'1': '2'}
        })
開發者ID:surajssd,項目名稱:atomicapp,代碼行數:25,代碼來源:test_nulecule.py

示例7: test_load_config_with_default_provider_overridden_by_answers

# 需要導入模塊: from atomicapp.nulecule.base import Nulecule [as 別名]
# 或者: from atomicapp.nulecule.base.Nulecule import load_config [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_config方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。