Пример #1
0
def test_CustomObject_config_schema(config_source, schema_source):
    with Schema.scope().registered(HOSTNAME=HOSTNAME, WORKDIR=WORKDIR), \
         Config.scope().registered(HOSTNAME=HOSTNAME, WORKDIR=WORKDIR):
        schema = Schema.from_string(schema_source)
        config = Config.from_string(config_source, schema=schema)
        assert config["x"] == HOSTNAME
        assert config["alpha"]["y"] == WORKDIR
        assert config["alpha"]["z"] == HOSTNAME + ":" + WORKDIR
Пример #2
0
def test_CustomObject_config_schema_to_string(config_source, schema_source, string_io):
    with Schema.scope().registered(HOSTNAME=HOSTNAME, WORKDIR=WORKDIR), \
         Config.scope().registered(HOSTNAME=HOSTNAME, WORKDIR=WORKDIR):
        schema = Schema.from_string(schema_source)
        config = Config.from_string(config_source, defaults=False, schema=schema)
        config.to_stream(string_io)
        s = string_io.getvalue()
        assert s == """\
Пример #3
0
def test_CustomObject_schema(schema_source, string_io):
    with Schema.scope().registered(HOSTNAME=HOSTNAME, WORKDIR=WORKDIR):
        schema = Schema.from_string(schema_source)
        schema.to_stream(string_io)