Example #1
0
  def test_config_and_option_are_added(self):
    """
    Test missing options and config are added
    """
    sys.argv += ['-vc']
    original_sysargv = sys.argv

    def fun():
      return 0

    options = ["--logfile /opt/slapos/logfile",
               "--pidfile /opt/slapos/pidfile"]
    config = '/etc/opt/slapos/slapos.cfg'
    try:
      entry.call(fun, config=config, option=options)
    except SystemExit, e:
      self.assertEqual(e[0], 0)
Example #2
0
  def test_config_and_missing_option_are_added(self):
    """
    Test missing options and config are added but do not replace
    already present option
    """
    missing_option = "--logfile /opt/slapos/logfile"
    present_option = "--pidfile /opt/slapos/pidfile"
    default_present_option = "--pidfile /opt/slapos/pidfile.default"
    sys.argv += ['-vc', present_option]
    original_sysargv = sys.argv

    def fun():
      return 0

    options = [default_present_option, missing_option]
    config = '/etc/opt/slapos/slapos.cfg'
    try:
      entry.call(fun, config=config, option=options)
    except SystemExit, e:
      self.assertEqual(e[0], 0)
Example #3
0
  def test_present_config_and_option_are_not_added(self):
    """
    Test already present options and config are not added
    """
    present_option = "--pidfile /opt/slapos/pidfile"
    default_present_option = "--pidfile /opt/slapos/pidfile.default"
    slapos_cfg = os.path.join(self._tempdir, 'slapos.cfg')
    open(slapos_cfg, 'w').write('[slapos]')
    sys.argv += ['-vc', slapos_cfg, present_option.split()[0],
                 present_option.split()[1]]
    original_sysargv = sys.argv

    def fun():
      return 0

    options = [default_present_option]
    config = '/etc/opt/slapos/slapos.cfg'
    try:
      entry.call(fun, config=config, option=options)
    except SystemExit, e:
      self.assertEqual(e[0], 0)