4
from landscape.tests.helpers import LandscapeTest
6
from landscape.sysvconfig import SysVConfig, ProcessError
9
class SysVConfigTest(LandscapeTest):
11
def test_set_to_run_on_boot(self):
12
filename = self.makeFile("RUN=0\n")
13
sysvconfig = SysVConfig(filename)
14
sysvconfig.set_start_on_boot(True)
15
self.assertEquals(file(filename, "r").read(), "RUN=1\n")
17
def test_set_to_not_run_on_boot(self):
18
filename = self.makeFile("RUN=1\n")
19
sysvconfig = SysVConfig(filename)
20
sysvconfig.set_start_on_boot(False)
21
self.assertEquals(file(filename, "r").read(), "RUN=0\n")
23
def test_is_landscape_configured_to_run(self):
24
filename = self.makeFile("RUN=1\n")
25
sysvconfig = SysVConfig(filename)
26
self.assertTrue(sysvconfig.is_configured_to_run(), True)
28
def test_is_landscape_configured_to_run(self):
29
filename = self.makeFile("RUN=0\n")
30
sysvconfig = SysVConfig(filename)
31
self.assertTrue(sysvconfig.is_configured_to_run(), False)
33
def test_run_landscape(self):
34
system = self.mocker.replace("os.system")
35
system("/etc/init.d/landscape-client restart")
37
filename = self.makeFile("RUN=1\n")
38
sysvconfig = SysVConfig(filename)
39
sysvconfig.restart_landscape()
41
def test_run_landscape_with_error(self):
42
system = self.mocker.replace("os.system")
43
system("/etc/init.d/landscape-client restart")
44
self.mocker.result(-1)
46
filename = self.makeFile("RUN=1\n")
47
sysvconfig = SysVConfig(filename)
48
self.assertRaises(ProcessError, sysvconfig.restart_landscape)
50
def test_stop_landscape(self):
51
system = self.mocker.replace("os.system")
52
system("/etc/init.d/landscape-client stop")
54
filename = self.makeFile("RUN=1\n")
55
sysvconfig = SysVConfig(filename)
56
sysvconfig.stop_landscape()
58
def test_stop_landscape(self):
59
system = self.mocker.replace("os.system")
60
system("/etc/init.d/landscape-client stop")
61
self.mocker.result(-1)
63
filename = self.makeFile("RUN=1\n")
64
sysvconfig = SysVConfig(filename)
65
self.assertRaises(ProcessError, sysvconfig.stop_landscape)