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


Python config_model.Configuration類代碼示例

本文整理匯總了Python中rubick.config_model.Configuration的典型用法代碼示例。如果您正苦於以下問題:Python Configuration類的具體用法?Python Configuration怎麽用?Python Configuration使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: test_contains

    def test_contains(self):
        c = Configuration()

        self.assertFalse(self.section in c)

        c.set(self.fullparam, self.value)
        self.assertTrue(self.section in c)
開發者ID:plomakin,項目名稱:rubick,代碼行數:7,代碼來源:test_configuration.py

示例2: test_subsection_getitem

    def test_subsection_getitem(self):
        c = Configuration()
        c.set(self.fullparam, self.value)

        cs = c.section(self.section)

        self.assertEqual(self.value, cs[self.param])
開發者ID:plomakin,項目名稱:rubick,代碼行數:7,代碼來源:test_configuration.py

示例3: test_parameter_names_containing_sections

    def test_parameter_names_containing_sections(self):
        c = Configuration()
        c.set(self.fullparam, self.value)

        self.assertEqual(
            self.value, c.get('%s.%s' %
                              (self.section, self.param)))
開發者ID:plomakin,項目名稱:rubick,代碼行數:7,代碼來源:test_configuration.py

示例4: test_subsection_setitem

    def test_subsection_setitem(self):
        c = Configuration()

        cs = c.section(self.section)

        cs[self.param] = self.value

        self.assertEqual(self.value, c.get(self.fullparam))
開發者ID:plomakin,項目名稱:rubick,代碼行數:8,代碼來源:test_configuration.py

示例5: test_explicit_default_on_get

    def test_explicit_default_on_get(self):
        c = Configuration()
        override_value = '12345'

        self.assertEqual(
            override_value,
            c.get(self.fullparam,
                  default=override_value))
開發者ID:plomakin,項目名稱:rubick,代碼行數:8,代碼來源:test_configuration.py

示例6: test_type_for_unknown_param

    def test_type_for_unknown_param(self):
        schema = ConfigSchema('test', '1.0', 'ini', [])

        c = Configuration(schema)

        c.set('param1', '123')

        self.assertEqual('123', c.get('param1'))
開發者ID:MirantisLabs,項目名稱:rubick,代碼行數:8,代碼來源:test_configuration.py

示例7: test_validate_returns_none_for_unknown_param

    def test_validate_returns_none_for_unknown_param(self):
        schema = ConfigSchema('test', '1.0', 'ini', [])

        c = Configuration(schema)

        c.set('param1', '123')

        self.assertIsNone(c.validate('param1'))
開發者ID:MirantisLabs,項目名稱:rubick,代碼行數:8,代碼來源:test_configuration.py

示例8: test_validate_returns_error_if_valid_is_invalid

    def test_validate_returns_error_if_valid_is_invalid(self):
        schema = ConfigSchema('test', '1.0', 'ini', [
            ConfigParameterSchema('param1', type='integer', section='DEFAULT')
        ])

        c = Configuration(schema)

        c.set('param1', 'abc')

        self.assertTrue(isinstance(c.validate('param1'), InvalidValueError))
開發者ID:MirantisLabs,項目名稱:rubick,代碼行數:10,代碼來源:test_configuration.py

示例9: test_validate_returns_none_if_value_is_valid

    def test_validate_returns_none_if_value_is_valid(self):
        schema = ConfigSchema('test', '1.0', 'ini', [
            ConfigParameterSchema('param1', type='integer', section='DEFAULT')
        ])

        c = Configuration(schema)

        c.set('param1', '123')

        self.assertIsNone(c.validate('param1'))
開發者ID:MirantisLabs,項目名稱:rubick,代碼行數:10,代碼來源:test_configuration.py

示例10: test_getting_typed_param_raw_value

    def test_getting_typed_param_raw_value(self):
        schema = ConfigSchema('test', '1.0', 'ini', [
            ConfigParameterSchema('param1', type='integer', section='DEFAULT')
        ])

        c = Configuration(schema)

        c.set('param1', '123')

        self.assertEqual('123', c.get('param1', raw=True))
開發者ID:MirantisLabs,項目名稱:rubick,代碼行數:10,代碼來源:test_configuration.py

示例11: test_typed_param_with_invalid_value_returns_string_value

    def test_typed_param_with_invalid_value_returns_string_value(self):
        schema = ConfigSchema('test', '1.0', 'ini', [
            ConfigParameterSchema('param1', type='integer', section='DEFAULT')
        ])

        c = Configuration(schema)

        c.set('param1', '123a')

        self.assertEqual('123a', c.get('param1'))
開發者ID:MirantisLabs,項目名稱:rubick,代碼行數:10,代碼來源:test_configuration.py

示例12: test_typed_params

    def test_typed_params(self):
        schema = ConfigSchema('test', '1.0', 'ini', [
            ConfigParameterSchema('param1', type='integer', section='DEFAULT')
        ])

        c = Configuration(schema)

        c.set('param1', '123')

        self.assertEqual(123, c.get('param1'))
開發者ID:MirantisLabs,項目名稱:rubick,代碼行數:10,代碼來源:test_configuration.py

示例13: config

    def config(self):
        config = Configuration()
        schema = ConfigSchemaRegistry.get_schema('rabbitmq', Version(1000000))
        if schema:
            for parameter in schema.parameters:
                if not parameter.default:
                    continue

                config.set_default(parameter.name, parameter.default)
        else:
            print("RabbitMQ schema not found")

        return config
開發者ID:ogelbukh,項目名稱:rubick,代碼行數:13,代碼來源:model.py

示例14: _parse_config_resources

    def _parse_config_resources(self, resources, schema=None):
        config = Configuration(schema)

        # Apply defaults
        if schema:
            for parameter in filter(lambda p: p.default, schema.parameters):
                if not parameter.section or parameter.section == 'DEFAULT':
                    config.set_default(parameter.name, parameter.default)
                else:
                    config.set_default(
                        '%s.%s' %
                        (parameter.section, parameter.name), parameter.default)

        for resource in reversed(resources):
            self._parse_config_file(
                Mark(resource.path), resource.contents, config, schema,
                issue_reporter=resource)

        return config
開發者ID:ogelbukh,項目名稱:rubick,代碼行數:19,代碼來源:model.py

示例15: test_subsection_contains

    def test_subsection_contains(self):
        c = Configuration()

        c.set('section1.param1', '123')
        c.set_default('section2.param2', '234')

        self.assertTrue('param1' in c.section('section1'))
        self.assertTrue('param2' in c.section('section2'))
        self.assertFalse('param1' in c.section('section2'))
開發者ID:plomakin,項目名稱:rubick,代碼行數:9,代碼來源:test_configuration.py


注:本文中的rubick.config_model.Configuration類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。