コード例 #1
0
    def test_merge_schemas_conflicts(self):
        class SchemaA(Schema):
            foo = IntOption()

        class SchemaB(Schema):
            foo = BoolOption()

        try:
            merge(SchemaA, SchemaB)
            self.fail('SchemaValidationError not raised.')
        except SchemaValidationError, e:
            self.assertEqual(str(e),
                "Conflicting option '__main__.foo' while merging schemas.")
コード例 #2
0
    def test_merge_schemas_conflicts(self):
        class SchemaA(Schema):
            foo = IntOption()

        class SchemaB(Schema):
            foo = BoolOption()

        try:
            merge(SchemaA, SchemaB)
            self.fail('SchemaValidationError not raised.')
        except SchemaValidationError, e:
            self.assertEqual(
                str(e),
                "Conflicting option '__main__.foo' while merging schemas.")
コード例 #3
0
ファイル: base.py プロジェクト: Alberto-Beralix/Beralix
    def __init__(self, app):
        schemas = [app.schema] + app.plugins.schemas
        self.schema = merge(*schemas)

        # initialize config
        config_files = self.get_config_files(app)
        self.glue = configglue(self.schema, config_files, op=app.parser)
コード例 #4
0
ファイル: base.py プロジェクト: iluminite/configglue
    def __init__(self, app):
        schemas = [app.schema] + app.plugins.schemas
        self.schema = merge(*schemas)

        # initialize config
        config_files = self.get_config_files(app)
        self.glue = configglue(self.schema, config_files, op=app.parser)
コード例 #5
0
    def test_merge_schemas_duplicate(self):
        class SchemaA(Schema):
            foo = IntOption()

        class SchemaB(Schema):
            foo = IntOption()

        schema = merge(SchemaA, SchemaB)()
        self.assertEqual(set(s.name for s in schema.sections()),
            set(['__main__']))
        self.assertEqual(set(o.name for o in schema.options('__main__')),
            set(['foo']))
        self.assertEqual(schema.foo, SchemaA().foo)
        self.assertEqual(schema.foo, SchemaB().foo)
コード例 #6
0
    def test_merge_schemas_no_conflicts(self):
        class SchemaA(Schema):
            foo = IntOption()

        class SchemaB(Schema):
            bar = BoolOption()

        schema = merge(SchemaA, SchemaB)()
        self.assertEqual(set(s.name for s in schema.sections()),
            set(['__main__']))
        self.assertEqual(set(o.name for o in schema.options('__main__')),
            set(['foo', 'bar']))
        self.assertEqual(schema.foo, SchemaA().foo)
        self.assertEqual(schema.bar, SchemaB().bar)
コード例 #7
0
    def test_merge_schemas_duplicate(self):
        class SchemaA(Schema):
            foo = IntOption()

        class SchemaB(Schema):
            foo = IntOption()

        schema = merge(SchemaA, SchemaB)()
        self.assertEqual(set(s.name for s in schema.sections()),
                         set(['__main__']))
        self.assertEqual(set(o.name for o in schema.options('__main__')),
                         set(['foo']))
        self.assertEqual(schema.foo, SchemaA().foo)
        self.assertEqual(schema.foo, SchemaB().foo)
コード例 #8
0
    def test_merge_schemas_no_conflicts(self):
        class SchemaA(Schema):
            foo = IntOption()

        class SchemaB(Schema):
            bar = BoolOption()

        schema = merge(SchemaA, SchemaB)()
        self.assertEqual(set(s.name for s in schema.sections()),
                         set(['__main__']))
        self.assertEqual(set(o.name for o in schema.options('__main__')),
                         set(['foo', 'bar']))
        self.assertEqual(schema.foo, SchemaA().foo)
        self.assertEqual(schema.bar, SchemaB().bar)
コード例 #9
0
    def test_merge_schemas_same_section(self):
        class SchemaA(Schema):
            class foo(Section):
                bar = IntOption()

        class SchemaB(Schema):
            class foo(Section):
                baz = BoolOption()

        schema = merge(SchemaA, SchemaB)()
        self.assertEqual(set(s.name for s in schema.sections()), set(['foo']))
        self.assertEqual(set(o.name for o in schema.options('foo')),
                         set(['bar', 'baz']))
        self.assertEqual(schema.foo.bar, SchemaA().foo.bar)
        self.assertEqual(schema.foo.baz, SchemaB().foo.baz)
コード例 #10
0
    def test_merge_schemas_same_section(self):
        class SchemaA(Schema):
            class foo(Section):
                bar = IntOption()

        class SchemaB(Schema):
            class foo(Section):
                baz = BoolOption()

        schema = merge(SchemaA, SchemaB)()
        self.assertEqual(set(s.name for s in schema.sections()),
            set(['foo']))
        self.assertEqual(set(o.name for o in schema.options('foo')),
            set(['bar', 'baz']))
        self.assertEqual(schema.foo.bar, SchemaA().foo.bar)
        self.assertEqual(schema.foo.baz, SchemaB().foo.baz)
コード例 #11
0
ファイル: schema.py プロジェクト: miing/mci_migo
        secure_ssl_redirect = BoolOption(default=True)
        secure_hsts_seconds = IntOption(default=300)
        secure_hsts_include_subdomains = BoolOption(default=True)
        secure_frame_deny = BoolOption(default=True)
        secure_content_type_nosniff = BoolOption(default=True)
        secure_browser_xss_filter = BoolOption(default=True)

    # override django section
    class django(DjangoSchema.django):
        caches = DictOption(item=UpperCaseDictOption())
        session_cookie_secure = BoolOption(default=True)
        session_cookie_httponly = BoolOption(default=True)

    class oopses(Section):
        oopses = OopsOption()


# merge all contrib schemas into the base schema
# order matters
schema = merge(
    SSOSchema,
    DevServerSchema,
    DjangoJenkinsSchema,
    DjangoOpenIdAuthSchema,
    NexusSchema,
    PreflightSchema,
    RavenSchema,
    Saml2IdpSchema,
    AdminAuditSchema,
)