Пример #1
0
 def _overrides(self, overrides={}):
     missing = []
     for key, value in list(overrides.items()):
         # I explicity check whether we're overriding an attribute on the
         # class. a) that's the intended semantic I want to check for and
         # b) this suppresses implicit __get__ conversions of Attribute
         # objects.
         if not hasattr(self.__class__, key):
             missing.append(key)
             continue
         setattr(self, key, value)
     if missing:
         raise batou.MissingOverrideAttributes(self, missing)
Пример #2
0
def test_config_exceptions_orderable(env):
    env.configure()
    c = env.get_root("zeo", env.hosts['localhost']).component

    import sys

    try:
        raise ValueError("Test")
    except Exception:
        exc_type, ex, tb = sys.exc_info()

    exceptions = [
        batou.ConfigurationError("test", None),
        batou.ConfigurationError("test", c),
        batou.ConversionError(c, "key", 123, int, "invalid int"),
        batou.MissingOverrideAttributes(c, ["sadf"]),
        batou.DuplicateComponent(c.root, c.root),
        batou.UnknownComponentConfigurationError(c.root, ex, tb),
        batou.UnusedResources({"asdf": [(c.root, 1)]}),
        batou.UnsatisfiedResources({"asdf": [c.root]}),
        batou.MissingEnvironment(env),
        batou.MissingComponent("asdf", "localhost"),
        batou.SuperfluousSection("asdf"),
        batou.SuperfluousComponentSection("asdf"),
        batou.SuperfluousSecretsSection("asdf"),
        batou.CycleErrorDetected(ValueError()),
        batou.NonConvergingWorkingSet([c]),
        batou.DeploymentError(),
        batou.DuplicateHostMapping("host", "map1", "map2"),
        batou.RepositoryDifferentError("asdf", "bsdf"),
        batou.DuplicateHostError("localhost"),
        batou.InvalidIPAddressError("asdf"), ]

    # Ensure all exceptions can be compared
    for x in exceptions:
        for y in exceptions:
            x.sort_key < y.sort_key