Add new RHEL7 logvol objects to master
[pykickstart.git] / tests / parser / packages.py
blobac764fa2cb80c202d440b340f349f773abcacf87
1 import unittest
2 from tests.baseclass import *
4 from pykickstart import constants
5 from pykickstart.errors import KickstartParseError
6 from pykickstart.version import RHEL6
8 class Packages_Contains_Comments_TestCase(ParserTest):
9 ks = """
10 %packages
11 packageA # this is an end-of-line comment
12 # this is a whole line comment
13 packageB
14 %end
15 """
17 def runTest(self):
18 self.parser.readKickstartFromString(self.ks)
20 # Verify that the packages are what we think they are.
21 self.assertEqual(len(self.handler.packages.packageList), 2)
22 self.assertEqual(self.handler.packages.packageList[0], "packageA")
23 self.assertEqual(self.handler.packages.packageList[1], "packageB")
25 class Packages_Contains_Nobase_1_TestCase(ParserTest):
26 ks = """
27 %packages --nobase
28 bash
29 %end
30 """
32 def runTest(self):
33 with warnings.catch_warnings(record=True) as w:
34 warnings.simplefilter("always")
35 self.parser.readKickstartFromString(self.ks)
36 self.assertEqual(len(w), 1)
37 self.assertIsInstance(w[-1].message, DeprecationWarning)
39 class Packages_Contains_Nobase_2_TestCase(ParserTest):
40 version = RHEL6
42 ks = """
43 %packages --nobase
44 bash
45 %end
46 """
48 def runTest(self):
49 with warnings.catch_warnings(record=True) as w:
50 warnings.simplefilter("always")
51 self.parser.readKickstartFromString(self.ks)
52 self.assertEqual(len(w), 0)
54 class Packages_Contains_Nobase_Default_TestCase(ParserTest):
55 ks = """
56 %packages --nobase --default
57 %end
58 """
60 def runTest(self):
61 with warnings.catch_warnings(record=True) as w:
62 warnings.simplefilter("always")
63 self.assertRaises(KickstartParseError, self.parser.readKickstartFromString, self.ks)
65 class Packages_Contains_Nocore_Default_TestCase(ParserTest):
66 ks = """
67 %packages --nocore --default
68 %end
69 """
71 def runTest(self):
72 with warnings.catch_warnings(record=True) as w:
73 warnings.simplefilter("always")
74 self.assertRaises(KickstartParseError, self.parser.readKickstartFromString, self.ks)
76 class Packages_Contains_Environment_1_TestCase(ParserTest):
77 ks = """
78 %packages
79 @^whatever-environment
80 %end
81 """
83 def runTest(self):
84 with warnings.catch_warnings(record=True) as w:
85 warnings.simplefilter("always")
86 self.parser.readKickstartFromString(self.ks)
87 self.assertEqual(self.handler.packages.environment, "whatever-environment")
89 class Packages_Contains_Environment_2_TestCase(ParserTest):
90 ks = """
91 %packages
92 @^whatever-environment
93 @^another-environment
94 %end
95 """
97 def runTest(self):
98 with warnings.catch_warnings(record=True) as w:
99 warnings.simplefilter("always")
100 self.parser.readKickstartFromString(self.ks)
101 self.assertEqual(self.handler.packages.environment, "another-environment")
103 class Packages_Contains_Environment_3_TestCase(ParserTest):
104 ks = """
105 %packages
106 @^whatever-environment
107 -@^another-environment
108 %end
111 def runTest(self):
112 with warnings.catch_warnings(record=True) as w:
113 warnings.simplefilter("always")
114 self.parser.readKickstartFromString(self.ks)
115 self.assertEqual(self.handler.packages.environment, "whatever-environment")
117 class Packages_Contains_Environment_4_TestCase(ParserTest):
118 ks = """
119 %packages
120 @^whatever-environment
121 -@^whatever-environment
122 @^another-environment
123 %end
126 def runTest(self):
127 with warnings.catch_warnings(record=True) as w:
128 warnings.simplefilter("always")
129 self.parser.readKickstartFromString(self.ks)
130 self.assertEqual(self.handler.packages.environment, "another-environment")
132 if __name__ == "__main__":
133 unittest.main()