Add new RHEL7 logvol objects to master
[pykickstart.git] / tests / commands / method.py
blob7ca643b877ac937c2f2f237a51b2d4223ce21705
2 # Martin Gracik <mgracik@redhat.com>
4 # Copyright 2009 Red Hat, Inc.
6 # This copyrighted material is made available to anyone wishing to use, modify,
7 # copy, or redistribute it subject to the terms and conditions of the GNU
8 # General Public License v.2. This program is distributed in the hope that it
9 # will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10 # implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 # See the GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License along with
14 # this program; if not, write to the Free Software Foundation, Inc., 51
15 # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16 # trademarks that are incorporated in the source code or documentation are not
17 # subject to the GNU General Public License and may only be used or replicated
18 # with the express permission of Red Hat, Inc.
21 import unittest
22 from tests.baseclass import *
24 class FC3_TestCase(CommandTest):
25 command = "method"
27 def runTest(self):
28 # pass
29 # cdrom
30 self.assert_parse("cdrom", "cdrom\n")
32 # harddrive
33 self.assert_parse("harddrive --dir=/install --biospart=part", "harddrive --dir=/install --biospart=part\n")
34 self.assert_parse("harddrive --dir=/install --partition=part", "harddrive --dir=/install --partition=part\n")
36 # nfs
37 self.assert_parse("nfs --server=1.2.3.4 --dir=/install", "nfs --server=1.2.3.4 --dir=/install\n")
39 # url
40 self.assert_parse("url --url=http://domain.com", "url --url=\"http://domain.com\"\n")
42 # fail
43 # harddrive
44 # required option --dir missing
45 self.assert_parse_error("harddrive", KickstartValueError)
46 # required --dir argument missing
47 self.assert_parse_error("harddrive --dir", KickstartParseError)
48 # missing --biospart or --partition option
49 self.assert_parse_error("harddrive --dir=/install", KickstartValueError)
50 # both --biospart and --partition specified
51 self.assert_parse_error("harddrive --dir=/install --biospart=bios --partition=part", KickstartValueError)
52 # --biospart and --partition require argument
53 self.assert_parse_error("harddrive --dir=/install --biospart", KickstartParseError)
54 self.assert_parse_error("harddrive --dir=/install --partition", KickstartParseError)
55 # unknown option
56 self.assert_parse_error("harddrive --unknown=value", KickstartParseError)
58 # nfs
59 # missing required options --server and --dir
60 self.assert_parse_error("nfs", KickstartValueError)
61 self.assert_parse_error("nfs --server=1.2.3.4", KickstartValueError)
62 self.assert_parse_error("nfs --server", KickstartParseError)
63 self.assert_parse_error("nfs --dir=/install", KickstartValueError)
64 self.assert_parse_error("nfs --dir", KickstartParseError)
65 # unknown option
66 self.assert_parse_error("nfs --unknown=value", KickstartParseError)
68 # url
69 # missing required option --url
70 self.assert_parse_error("url", KickstartValueError)
71 self.assert_parse_error("url --url", KickstartParseError)
74 class FC6_TestCase(FC3_TestCase):
75 def runTest(self):
76 # run FC3 test case
77 FC3_TestCase.runTest(self)
79 # pass
80 # nfs
81 self.assert_parse("nfs --server=1.2.3.4 --dir=/install --opts=options", "nfs --server=1.2.3.4 --dir=/install --opts=\"options\"\n")
83 # fail
84 # nfs
85 # --opts requires argument if specified
86 self.assert_parse_error("nfs --server=1.2.3.4 --dir=/install --opts", KickstartParseError)
89 class F13_TestCase(FC6_TestCase):
90 def runTest(self):
91 # run FC6 test case
92 FC6_TestCase.runTest(self)
94 # pass
95 self.assert_parse("url --url=http://someplace/somewhere --proxy=http://wherever/other",
96 "url --url=\"http://someplace/somewhere\" --proxy=\"http://wherever/other\"\n")
98 # fail
99 self.assert_parse_error("cdrom --proxy=http://someplace/somewhere", KickstartParseError)
100 self.assert_parse_error("url --url=http://someplace/somewhere --proxy", KickstartParseError)
101 self.assert_parse_error("url --proxy=http://someplace/somewhere", KickstartValueError)
103 class F14_TestCase(F13_TestCase):
104 def runTest(self):
105 # run FC6 test case
106 F13_TestCase.runTest(self)
108 # pass
109 self.assert_parse("url --url=https://someplace/somewhere --noverifyssl",
110 "url --url=\"https://someplace/somewhere\" --noverifyssl\n")
112 # fail
113 self.assert_parse_error("cdrom --noverifyssl", KickstartParseError)
115 class F18_TestCase(F14_TestCase):
116 def runTest(self):
117 # run F14 test case.
118 F14_TestCase.runTest(self)
120 # pass
121 self.assert_parse("url --mirrorlist=http://www.wherever.com/mirror",
122 "url --mirrorlist=\"http://www.wherever.com/mirror\"\n")
124 # fail
125 # missing one of required options --url or --mirrorlist
126 self.assert_parse_error("url", KickstartValueError)
127 self.assert_parse_error("url --mirrorlist", KickstartParseError)
129 # It's --url, not --baseurl.
130 self.assert_parse_error("url --baseurl=www.wherever.com", KickstartParseError)
132 # only one of --url or --mirrorlist may be specified
133 self.assert_parse_error("url --url=www.wherever.com --mirrorlist=www.wherever.com",
134 KickstartValueError)
136 class F19_TestCase(F18_TestCase):
137 def runTest(self):
138 # run F18 test case.
139 F18_TestCase.runTest(self)
141 # liveimg pass
142 self.assert_parse("liveimg --url=http://someplace/somewhere --proxy=http://wherever/other "
143 "--noverifyssl --checksum=e7a9fe500330a1cae4ca114833bb3df014e6d14e63ea9566896a848f3832d0ba",
144 "liveimg --url=\"http://someplace/somewhere\" --proxy=\"http://wherever/other\" "
145 "--noverifyssl --checksum=\"e7a9fe500330a1cae4ca114833bb3df014e6d14e63ea9566896a848f3832d0ba\"\n")
146 self.assert_parse("liveimg --url=http://someplace/somewhere --proxy=http://wherever/other "
147 "--noverifyssl",
148 "liveimg --url=\"http://someplace/somewhere\" --proxy=\"http://wherever/other\" "
149 "--noverifyssl\n")
150 self.assert_parse("liveimg --url=http://someplace/somewhere --proxy=http://wherever/other ",
151 "liveimg --url=\"http://someplace/somewhere\" --proxy=\"http://wherever/other\"\n")
152 self.assert_parse("liveimg --url=http://someplace/somewhere",
153 "liveimg --url=\"http://someplace/somewhere\"\n")
155 # liveimg fail
156 self.assert_parse_error("liveimg", KickstartValueError)
157 self.assert_parse_error("liveimg --url", KickstartParseError)
158 self.assert_parse_error("liveimg --url=http://someplace/somewhere --proxy", KickstartParseError)
159 self.assert_parse_error("liveimg --proxy=http://someplace/somewhere", KickstartValueError)
160 self.assert_parse_error("liveimg --noverifyssl", KickstartValueError)
161 self.assert_parse_error("liveimg --checksum=e7a9fe500330a1cae4ca114833bb3df014e6d14e63ea9566896a848f3832d0ba", KickstartValueError)
164 if __name__ == "__main__":
165 unittest.main()