Add new RHEL7 logvol objects to master
[pykickstart.git] / tests / commands / repo.py
blobb944c54831ae59b917b8232c04051511ecaafa11
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 FC6_TestCase(CommandTest):
25 command = "repo"
27 def runTest(self, urlRequired=True):
28 # pass
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")
34 # equality
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"))
40 # fail
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
45 if urlRequired:
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",
51 KickstartValueError)
52 # unknown option
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):
59 # run FC6 test case
60 FC6_TestCase.runTest(self, urlRequired=urlRequired)
62 # pass
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")
68 # fail
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):
77 # run F8 test case
78 F8_TestCase.runTest(self, urlRequired=urlRequired)
80 # pass
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")
88 # fail
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):
94 # run F11 test case
95 F11_TestCase.runTest(self, urlRequired=urlRequired)
97 # pass
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")
103 # fail
104 # missing --proxy argument
105 self.assert_parse_error("repo --name=blah --baseurl=www.domain.com --proxy",
106 KickstartParseError)
108 class F14_TestCase(F13_TestCase):
109 def runTest(self, urlRequired=True):
110 F13_TestCase.runTest(self, urlRequired=urlRequired)
111 #pass
112 self.assert_parse("repo --name=blah --baseurl=https://www.domain.com --noverifyssl",
113 "repo --name=\"blah\" --baseurl=https://www.domain.com --noverifyssl\n")
114 #fail
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)
124 #pass
125 self.assert_parse("repo --name=blah --baseurl=https://www.domain.com --install",
126 "repo --name=\"blah\" --baseurl=https://www.domain.com --install\n")
127 #fail
128 self.assert_parse_error("repo --name=blah --baseurl=https://www.domain.com --install=yeeeaah", KickstartParseError)
131 if __name__ == "__main__":
132 unittest.main()