2 from tests
.baseclass
import *
4 from pykickstart
import constants
5 from pykickstart
.errors
import KickstartParseError
6 from pykickstart
import version
8 class Simple_Terminated_TestCase(ParserTest
):
16 self
.parser
.readKickstartFromString(self
.ks
)
17 self
.assertEqual(len(self
.handler
.scripts
), 1)
19 # Verify the script defaults.
20 script
= self
.handler
.scripts
[0]
21 self
.assertEqual(script
.interp
, "/bin/sh")
22 self
.assertFalse(script
.inChroot
)
23 self
.assertEqual(script
.lineno
, 2)
24 self
.assertFalse(script
.errorOnFail
)
25 self
.assertEqual(script
.type, constants
.KS_SCRIPT_PRE
)
27 # Also verify the body, which is the most important part.
28 self
.assertEqual(script
.script
.rstrip(), "ls /tmp")
30 class Simple_Header_TestCase(ParserTest
):
32 %pre --interpreter /usr/bin/python --erroronfail --log=/tmp/blah
38 self
.parser
.readKickstartFromString(self
.ks
)
39 self
.assertEqual(len(self
.handler
.scripts
), 1)
41 # Verify the changes we made in the header.
42 script
= self
.handler
.scripts
[0]
43 self
.assertEqual(script
.interp
, "/usr/bin/python")
44 self
.assertFalse(script
.inChroot
)
45 self
.assertTrue(script
.errorOnFail
)
46 self
.assertEqual(script
.lineno
, 2)
47 self
.assertEqual(script
.type, constants
.KS_SCRIPT_PRE
)
48 self
.assertEqual(script
.logfile
, "/tmp/blah")
50 # Also verify the body, which is the most important part.
51 self
.assertEqual(script
.script
.rstrip(), "ls /tmp")
53 class Pre_Given_Nochroot_TestCase(ParserTest
):
61 self
.assertRaises(KickstartParseError
, self
.parser
.readKickstartFromString
, self
.ks
)
63 class Multiple_Terminated_TestCase(ParserTest
):
75 self
.parser
.readKickstartFromString(self
.ks
)
76 self
.assertEqual(len(self
.handler
.scripts
), 2)
78 # Verify the script defaults.
79 script
= self
.handler
.scripts
[0]
80 self
.assertEqual(script
.interp
, "/bin/sh")
81 self
.assertFalse(script
.inChroot
)
82 self
.assertFalse(script
.errorOnFail
)
83 self
.assertEqual(script
.lineno
, 2)
84 self
.assertEqual(script
.type, constants
.KS_SCRIPT_PRE
)
86 # Also verify the body, which is the most important part.
87 self
.assertEqual(script
.script
.rstrip(), "ls /tmp")
89 script
= self
.handler
.scripts
[1]
90 self
.assertEqual(script
.script
.rstrip(), "ls /var")
92 class Simple_Unterminated_TestCase(Simple_Terminated_TestCase
):
100 class Simple_Unterminated_Fails_TestCase(Simple_Unterminated_TestCase
):
104 self
.assertRaises(KickstartParseError
, self
.parser
.readKickstartFromString
, self
.ks
)
106 class Multiple_Unterminated_TestCase(Multiple_Terminated_TestCase
):
117 class Multiple_Unterminated_Fails_TestCase(Multiple_Unterminated_TestCase
):
121 self
.assertRaises(KickstartParseError
, self
.parser
.readKickstartFromString
, self
.ks
)
123 if __name__
== "__main__":