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.
22 from tests
.baseclass
import *
24 class FC3_TestCase(CommandTest
):
30 self
.assert_parse("cdrom", "cdrom\n")
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")
37 self
.assert_parse("nfs --server=1.2.3.4 --dir=/install", "nfs --server=1.2.3.4 --dir=/install\n")
40 self
.assert_parse("url --url=http://domain.com", "url --url=\"http://domain.com\"\n")
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
)
56 self
.assert_parse_error("harddrive --unknown=value", KickstartParseError
)
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
)
66 self
.assert_parse_error("nfs --unknown=value", KickstartParseError
)
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
):
77 FC3_TestCase
.runTest(self
)
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")
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
):
92 FC6_TestCase
.runTest(self
)
95 self
.assert_parse("url --url=http://someplace/somewhere --proxy=http://wherever/other",
96 "url --url=\"http://someplace/somewhere\" --proxy=\"http://wherever/other\"\n")
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
):
106 F13_TestCase
.runTest(self
)
109 self
.assert_parse("url --url=https://someplace/somewhere --noverifyssl",
110 "url --url=\"https://someplace/somewhere\" --noverifyssl\n")
113 self
.assert_parse_error("cdrom --noverifyssl", KickstartParseError
)
115 class F18_TestCase(F14_TestCase
):
118 F14_TestCase
.runTest(self
)
121 self
.assert_parse("url --mirrorlist=http://www.wherever.com/mirror",
122 "url --mirrorlist=\"http://www.wherever.com/mirror\"\n")
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",
136 class F19_TestCase(F18_TestCase
):
139 F18_TestCase
.runTest(self
)
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 "
148 "liveimg --url=\"http://someplace/somewhere\" --proxy=\"http://wherever/other\" "
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")
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__":