Ejemplo n.º 1
0
def root(tmpdir):
    environment = Environment("test", basedir=str(tmpdir))
    environment._set_defaults()
    os.chdir(str(tmpdir))

    class MyComponent(Component):
        pass

    compdef = ComponentDefinition(MyComponent)
    compdef.defdir = str(tmpdir)
    environment.components[compdef.name] = compdef
    root = environment.add_root(compdef.name, "host")
    root.prepare()
    root.component.deploy()
    return root
Ejemplo n.º 2
0
def test_configurationerrors_can_be_sorted(root):
    errors = []
    errors.append(ConfigurationError("asdffdas", root.component))
    errors.append(
        ConversionError(root.component, "testkey", "testvalue", str, "foobar"))
    errors.append(MissingOverrideAttributes(root.component, ["asdf", "bsdfg"]))

    errors.append(
        DuplicateComponent(
            ComponentDefinition(root.component.__class__, "asdf.py"),
            ComponentDefinition(root.component.__class__, "bsdf.py"),
        ))

    try:
        raise ValueError("asdf")
    except Exception:
        _, exc_value, exc_traceback = sys.exc_info()

    errors.append(
        UnknownComponentConfigurationError(root, exc_value, exc_traceback))

    errors.append(UnusedResources({"asdf": [(root.component, 1)]}))

    errors.append(UnsatisfiedResources({"asdf": [root]}))

    errors.append(MissingEnvironment(root.environment))

    errors.append(ComponentLoadingError("asdf.py", ValueError("asdf")))

    errors.append(MissingComponent("component", "hostname"))

    errors.append(SuperfluousSection("asdf"))

    errors.append(SuperfluousComponentSection("asdf"))

    errors.append(SuperfluousSecretsSection("asdf"))

    errors.append(CycleErrorDetected("foo"))

    errors.append(NonConvergingWorkingSet([root]))

    errors.append(DuplicateHostError("asdf"))

    errors.append(InvalidIPAddressError(("127.0.0.256/24")))

    errors.sort(key=lambda x: x.sort_key)
Ejemplo n.º 3
0
def env():
    env = Environment("test")
    for component in list(globals().values()):
        if not isinstance(component, type):
            continue
        if issubclass(component, Component):
            compdef = ComponentDefinition(component)
            env.components[compdef.name] = compdef
    return env