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 FC6_TestCase(CommandTest
):
27 def runTest(self
, urlRequired
=True):
29 self
.assert_parse("repo --name=blah --baseurl=http://www.domain.com",
30 "repo --name=\"blah\" --baseurl=http://www.domain.com\n")
31 self
.assert_parse("repo --name=blah --mirrorlist=http://www.domain.com",
32 "repo --name=\"blah\" --mirrorlist=http://www.domain.com\n")
35 self
.assertEqual(self
.assert_parse("repo --name=left --baseurl=http://wherever"), self
.assert_parse("repo --name=left --baseurl=http://wherever"))
36 self
.assertEqual(self
.assert_parse("repo --name=left --baseurl=http://wherever"), self
.assert_parse("repo --name=left --baseurl=http://somewhere"))
37 self
.assertNotEqual(self
.assert_parse("repo --name=left --baseurl=http://wherever"), None)
38 self
.assertNotEqual(self
.assert_parse("repo --name=left --baseurl=http://wherever"), self
.assert_parse("repo --name=right --baseurl=http://wherever"))
41 # missing required option --name
42 self
.assert_parse_error("repo --baseurl=www.domain.com", KickstartValueError
)
43 self
.assert_parse_error("repo --name --baseurl=www.domain.com", KickstartParseError
)
44 # missing one of required options --baseurl or --mirrorlist
46 self
.assert_parse_error("repo --name=blah", KickstartValueError
)
47 self
.assert_parse_error("repo --name=blah --baseurl", KickstartParseError
)
48 self
.assert_parse_error("repo --name=blah --mirrorlist", KickstartParseError
)
49 # only one of --baseurl or --mirrorlist must be specified
50 self
.assert_parse_error("repo --name=blah --baseurl=www.domain.com --mirrorlist=www.domain.com",
53 self
.assert_parse_error("repo --name=blah --baseurl=www.domain.com --unknown", KickstartParseError
)
54 # not expected argument
55 self
.assert_parse_error("repo --name=blah --baseurl=www.domain.com blah", KickstartValueError
)
57 class F8_TestCase(FC6_TestCase
):
58 def runTest(self
, urlRequired
=True):
60 FC6_TestCase
.runTest(self
, urlRequired
=urlRequired
)
63 self
.assert_parse("repo --name=blah --baseurl=www.domain.com --cost=10 --excludepkgs=pkg1,pkg2 --includepkgs=pkg3,pkg4",
64 "repo --name=\"blah\" --baseurl=www.domain.com --cost=10 --includepkgs=\"pkg3,pkg4\" --excludepkgs=\"pkg1,pkg2\"\n")
65 self
.assert_parse("repo --name=blah --baseurl=123xyz --cost=10 --excludepkgs=pkg1,pkg2 --includepkgs=pkg3,pkg4",
66 "repo --name=\"blah\" --baseurl=123xyz --cost=10 --includepkgs=\"pkg3,pkg4\" --excludepkgs=\"pkg1,pkg2\"\n")
69 # missing required arguments
70 for opt
in ("--cost", "--includepkgs", "--excludepkgs"):
71 self
.assert_parse_error("repo --name=blah --baseurl=www.domain.com %s" % opt
, KickstartParseError
)
72 # --cost argument not integer
73 self
.assert_parse_error("repo --name=blah --baseurl=www.domain.com --cost=high", KickstartParseError
)
75 class F11_TestCase(F8_TestCase
):
76 def runTest(self
, urlRequired
=True):
78 F8_TestCase
.runTest(self
, urlRequired
=urlRequired
)
81 for val
in ("1", "true", "on"):
82 self
.assert_parse("repo --name=blah --baseurl=www.domain.com --cost=10 --excludepkgs=pkg1,pkg2 --includepkgs=pkg3,pkg4 --ignoregroups=%s" % val
,
83 "repo --name=\"blah\" --baseurl=www.domain.com --cost=10 --includepkgs=\"pkg3,pkg4\" --excludepkgs=\"pkg1,pkg2\" --ignoregroups=true\n")
84 for val
in ("0", "false", "off"):
85 self
.assert_parse("repo --name=blah --baseurl=www.domain.com --cost=10 --excludepkgs=pkg1,pkg2 --includepkgs=pkg3,pkg4 --ignoregroups=%s" % val
,
86 "repo --name=\"blah\" --baseurl=www.domain.com --cost=10 --includepkgs=\"pkg3,pkg4\" --excludepkgs=\"pkg1,pkg2\"\n")
89 # missing --ignoregroups argument
90 self
.assert_parse_error("repo --name=blah --baseurl=www.domain.com --ignoregroups", KickstartParseError
)
92 class F13_TestCase(F11_TestCase
):
93 def runTest(self
, urlRequired
=True):
95 F11_TestCase
.runTest(self
, urlRequired
=urlRequired
)
98 self
.assert_parse("repo --name=blah --baseurl=www.domain.com --proxy=http://someplace/wherever",
99 "repo --name=\"blah\" --baseurl=www.domain.com --proxy=\"http://someplace/wherever\"\n")
100 self
.assert_parse("repo --name=blah --baseurl=www.domain.com --proxy=\"http://someplace/wherever\"",
101 "repo --name=\"blah\" --baseurl=www.domain.com --proxy=\"http://someplace/wherever\"\n")
104 # missing --proxy argument
105 self
.assert_parse_error("repo --name=blah --baseurl=www.domain.com --proxy",
108 class F14_TestCase(F13_TestCase
):
109 def runTest(self
, urlRequired
=True):
110 F13_TestCase
.runTest(self
, urlRequired
=urlRequired
)
112 self
.assert_parse("repo --name=blah --baseurl=https://www.domain.com --noverifyssl",
113 "repo --name=\"blah\" --baseurl=https://www.domain.com --noverifyssl\n")
115 self
.assert_parse_error("repo --name=blah --baseurl=https://www.domain.com --noverifyssl=yeeeaah", KickstartParseError
)
117 class F15_TestCase(F14_TestCase
):
118 def runTest(self
, urlRequired
=False):
119 F14_TestCase
.runTest(self
, urlRequired
=urlRequired
)
121 class F21_TestCase(F15_TestCase
):
122 def runTest(self
, urlRequired
=False):
123 F15_TestCase
.runTest(self
, urlRequired
=urlRequired
)
125 self
.assert_parse("repo --name=blah --baseurl=https://www.domain.com --install",
126 "repo --name=\"blah\" --baseurl=https://www.domain.com --install\n")
128 self
.assert_parse_error("repo --name=blah --baseurl=https://www.domain.com --install=yeeeaah", KickstartParseError
)
131 if __name__
== "__main__":