Beispiel #1
0
 def test_assignment_unmapped(self):
     GetPrefix.set_assignment('new.foo',
                              23,
                              MASTER,
                              self.slave,
                              unmapped_keys=set(['new']))
     self.assertEqual(self.slave, {'new': {'foo': 23}})
Beispiel #2
0
    def _args_to_settings(self, args, error):
        args = ' '.join(args)
        settings = {}
        base_settings = self.file_settings[0][1][0]
        assert isinstance(base_settings, dict)
        try:
            split_args = Args.split(args)
        except Exception as e:
            e.arg = '%s %s' % (error, args)
            raise

        for addr, value in split_args:
            try:
                GetPrefix.set_assignment(
                    addr,
                    value,
                    base_settings,
                    settings,
                    unmapped_keys=Merge.SETTINGS_EXCEPTIONS)
            except GetPrefix.PrefixException:
                raise Exception('Can\'t understand settings address "%s"' %
                                addr)
            except Exception:
                raise Exception(
                    'Can\'t understand settings value "%s" in %s=%s' %
                    (value, addr, value))
        return settings
Beispiel #3
0
  def _assignment_to_config(self, args, error):
    args = ' '.join(args)
    config = {}
    base_config = self.file_configs[0][1][0]
    assert isinstance(base_config, dict)
    try:
      split_args = Args.split(args)
    except Exception as e:
      e.arg = '%s %s' % (error, args)
      raise

    for addr, value in split_args:
      try:
        GetPrefix.set_assignment(addr, value, base_config, config,
                                 unmapped_names=Merge.CONFIG_EXCEPTIONS)
      except GetPrefix.PrefixException:
        raise Exception('Can\'t understand configuration address "%s"' % addr)
      except Exception:
        raise Exception('Can\'t understand configuration value "%s" in %s=%s' %
                        (value, addr, value))
    return config
Beispiel #4
0
    def _args_to_settings(self, args, error):
        args = ' '.join(args)
        settings = {}
        base_settings = self.file_settings[0][1][0]
        assert isinstance(base_settings, dict)
        try:
            split_args = Args.split(args)
        except Exception as e:
            e.arg = '%s %s' % (error, args)
            raise

        for addr, value in split_args:
            try:
                GetPrefix.set_assignment(
                    addr, value, base_settings, settings,
                    unmapped_keys=Merge.SETTINGS_EXCEPTIONS)
            except GetPrefix.PrefixException:
                raise Exception('Can\'t understand settings address "%s"' %
                                addr)
            except Exception:
                raise Exception(
                    'Can\'t understand settings value "%s" in %s=%s' %
                    (value, addr, value))
        return settings
Beispiel #5
0
 def test_assignment_unmapped(self):
   GetPrefix.set_assignment('new.foo', 23, MASTER, self.slave,
                            unmapped_names=set(['new']))
   self.assertEqual(self.slave, {'new': {'foo': 23}})
Beispiel #6
0
 def test_assignment_prefix(self):
   GetPrefix.set_assignment('f.b.b', 19, MASTER, self.slave)
   self.assertEqual(self.slave, {'foo': {'bar': {'baz': 19}}})
Beispiel #7
0
 def test_assignment(self):
   GetPrefix.set_assignment('foo.bar.baz', 32, MASTER, self.slave)
   self.assertEqual(self.slave, {'foo': {'bar': {'baz': 32}}})
Beispiel #8
0
 def test_assignment_prefix(self):
     GetPrefix.set_assignment('f.b.b', 19, MASTER, self.slave)
     self.assertEqual(self.slave, {'foo': {'bar': {'baz': 19}}})
Beispiel #9
0
 def test_assignment(self):
     GetPrefix.set_assignment('foo.bar.baz', 32, MASTER, self.slave)
     self.assertEqual(self.slave, {'foo': {'bar': {'baz': 32}}})