def test_no_message(self):
     # if message is not present, then no argument should be passed for it
     cfg = {'power_state': {'mode': 'poweroff'}}
     (cmd, _timeout) = psc.load_power_state(cfg)
     self.assertNotIn("", cmd)
     check_lps_ret(psc.load_power_state(cfg))
     self.assertTrue(len(cmd) == 3)
 def test_no_message(self):
     # if message is not present, then no argument should be passed for it
     cfg = {'power_state': {'mode': 'poweroff'}}
     (cmd, _timeout, _condition) = psc.load_power_state(cfg)
     self.assertNotIn("", cmd)
     check_lps_ret(psc.load_power_state(cfg))
     self.assertTrue(len(cmd) == 3)
Beispiel #3
0
 def test_freebsd_poweroff_uses_lowercase_p(self):
     cls = distros.fetch('freebsd')
     paths = helpers.Paths({})
     freebsd = cls('freebsd', {}, paths)
     cfg = {'power_state': {'mode': 'poweroff'}}
     ret = psc.load_power_state(cfg, freebsd)
     self.assertIn('-p', ret[0])
Beispiel #4
0
 def test_freebsd_poweroff_uses_lowercase_p(self):
     cls = distros.fetch("freebsd")
     paths = helpers.Paths({})
     freebsd = cls("freebsd", {}, paths)
     cfg = {"power_state": {"mode": "poweroff"}}
     ret = psc.load_power_state(cfg, freebsd)
     self.assertIn("-p", ret[0])
Beispiel #5
0
 def test_alpine_delay(self):
     # alpine takes delay in seconds.
     cls = distros.fetch('alpine')
     paths = helpers.Paths({})
     alpine = cls('alpine', {}, paths)
     cfg = {'power_state': {'mode': 'poweroff', 'delay': ''}}
     for delay, value in (('now', 0), ("+1", 60), ("+30", 1800)):
         cfg['power_state']['delay'] = delay
         ret = psc.load_power_state(cfg, alpine)
         self.assertEqual('-d', ret[0][1])
         self.assertEqual(str(value), ret[0][2])
Beispiel #6
0
 def test_alpine_delay(self):
     # alpine takes delay in seconds.
     cls = distros.fetch("alpine")
     paths = helpers.Paths({})
     alpine = cls("alpine", {}, paths)
     cfg = {"power_state": {"mode": "poweroff", "delay": ""}}
     for delay, value in (("now", 0), ("+1", 60), ("+30", 1800)):
         cfg["power_state"]["delay"] = delay
         ret = psc.load_power_state(cfg, alpine)
         self.assertEqual("-d", ret[0][1])
         self.assertEqual(str(value), ret[0][2])
Beispiel #7
0
 def test_irrelevant_config(self):
     # no power_state field in config should return None for cmd
     (cmd, _timeout, _condition) = psc.load_power_state({"foo": "bar"},
                                                        self.dist)
     self.assertIsNone(cmd)
 def test_no_config(self):
     # completely empty config should mean do nothing
     (cmd, _timeout) = psc.load_power_state({})
     self.assertEqual(cmd, None)
 def test_valid_delay(self):
     cfg = {'power_state': {'mode': 'poweroff', 'delay': ''}}
     for delay in ("now", "+1", "+30"):
         cfg['power_state']['delay'] = delay
         check_lps_ret(psc.load_power_state(cfg))
 def test_message_present(self):
     cfg = {'power_state': {'mode': 'poweroff', 'message': 'GOODBYE'}}
     ret = psc.load_power_state(cfg)
     check_lps_ret(psc.load_power_state(cfg))
     self.assertIn(cfg['power_state']['message'], ret[0])
Beispiel #11
0
 def test_valid_delay(self):
     cfg = {"power_state": {"mode": "poweroff", "delay": ""}}
     for delay in ("now", "+1", "+30"):
         cfg["power_state"]["delay"] = delay
         check_lps_ret(psc.load_power_state(cfg, self.dist))
Beispiel #12
0
 def test_valid_modes(self):
     cfg = {"power_state": {}}
     for mode in ("halt", "poweroff", "reboot"):
         cfg["power_state"]["mode"] = mode
         check_lps_ret(psc.load_power_state(cfg, self.dist), mode=mode)
 def test_valid_delay(self):
     cfg = {'power_state': {'mode': 'poweroff', 'delay': ''}}
     for delay in ("now", "+1", "+30"):
         cfg['power_state']['delay'] = delay
         check_lps_ret(psc.load_power_state(cfg))
 def test_irrelevant_config(self):
     # no power_state field in config should return None for cmd
     (cmd, _timeout, _condition) = psc.load_power_state({'foo': 'bar'})
     self.assertEqual(cmd, None)
 def test_no_config(self):
     # completely empty config should mean do nothing
     (cmd, _timeout, _condition) = psc.load_power_state({}, 'ubuntu')
     self.assertIsNone(cmd)
Beispiel #16
0
 def test_condition_default_is_true(self):
     cfg = {"power_state": {"mode": "poweroff"}}
     _cmd, _timeout, cond = psc.load_power_state(cfg, self.dist)
     self.assertEqual(cond, True)
Beispiel #17
0
 def test_message_present(self):
     cfg = {"power_state": {"mode": "poweroff", "message": "GOODBYE"}}
     ret = psc.load_power_state(cfg, self.dist)
     check_lps_ret(psc.load_power_state(cfg, self.dist))
     self.assertIn(cfg["power_state"]["message"], ret[0])
 def test_no_config(self):
     # completely empty config should mean do nothing
     (cmd, _timeout, _condition) = psc.load_power_state({})
     self.assertEqual(cmd, None)
 def test_condition_default_is_true(self):
     cfg = {'power_state': {'mode': 'poweroff'}}
     _cmd, _timeout, cond = psc.load_power_state(cfg)
     self.assertEqual(cond, True)
 def test_valid_modes(self):
     cfg = {'power_state': {}}
     for mode in ('halt', 'poweroff', 'reboot'):
         cfg['power_state']['mode'] = mode
         check_lps_ret(psc.load_power_state(cfg), mode=mode)
 def test_irrelevant_config(self):
     # no power_state field in config should return None for cmd
     (cmd, _timeout) = psc.load_power_state({'foo': 'bar'})
     self.assertEqual(cmd, None)
 def test_message_present(self):
     cfg = {'power_state': {'mode': 'poweroff', 'message': 'GOODBYE'}}
     ret = psc.load_power_state(cfg)
     check_lps_ret(psc.load_power_state(cfg))
     self.assertIn(cfg['power_state']['message'], ret[0])
 def test_valid_modes(self):
     cfg = {'power_state': {}}
     for mode in ('halt', 'poweroff', 'reboot'):
         cfg['power_state']['mode'] = mode
         check_lps_ret(psc.load_power_state(cfg), mode=mode)
 def test_condition_default_is_true(self):
     cfg = {'power_state': {'mode': 'poweroff'}}
     _cmd, _timeout, cond = psc.load_power_state(cfg)
     self.assertEqual(cond, True)
 def test_no_config(self):
     # completely empty config should mean do nothing
     (cmd, _timeout, _condition) = psc.load_power_state({})
     self.assertIsNone(cmd)