qubes-installer-qubes-os/anaconda/old_tests/pyanaconda_test/bootloader_test.py
Marek Marczykowski-Górecki f73b3741f0 Update anaconda to 20.25.16
Apply result of "git diff anaconda-18.37.11-1..anaconda-20.25.16-1" and
resolve conflicts.
2014-04-08 05:50:31 +02:00

60 lines
2.1 KiB
Python

import mock
class ArgumentsTest(mock.TestCase):
def setUp(self):
self.setupModules(
['_isys', 'logging', 'pyanaconda.anaconda_log', 'block',
'pyanaconda.storage',
'pyanaconda.storage.devicelibs',
'pyanaconda.storage.errors'])
import pyanaconda
pyanaconda.anaconda_log = mock.Mock()
def tearDown(self):
self.tearDownModules()
def test_basic(self):
from pyanaconda.bootloader import Arguments
a = Arguments()
a.update(set(["a", "b", "c"]))
b = Arguments()
b.add("b")
diff = a - b
self.assertEqual(diff, set(["a", "c"]))
self.assertIsInstance(diff, Arguments)
assert(str(diff) in ["a c", "c a"])
def test_merge_ip(self):
from pyanaconda.bootloader import Arguments
# test that _merge_ip() doesnt break the simple case:
a = Arguments(["one", "two", "ip=eth0:dhcp"])
a._merge_ip()
self.assertEqual(a, Arguments(["one", "two", "ip=eth0:dhcp"]))
# test that it does what it's supposed to:
a = Arguments(["one", "two", "ip=eth0:dhcp", "ip=eth0:auto6",
"ip=wlan0:dhcp",
"ip=10.34.102.102::10.34.39.255:24:aklab:eth2:none"])
a._merge_ip()
self.assertEqual(a, set([
"one", "two",
"ip=wlan0:dhcp",
"ip=10.34.102.102::10.34.39.255:24:aklab:eth2:none",
"ip=eth0:auto6,dhcp"]))
def test_output_with_merge(self):
from pyanaconda.bootloader import Arguments
a = Arguments(["ip=eth0:dhcp"])
self.assertEqual(str(a), "ip=eth0:dhcp")
a = Arguments(["ip=eth0:dhcp", "ip=eth0:auto6"])
assert(str(a) in ["ip=eth0:auto6,dhcp", "ip=eth0:dhcp,auto6"])
def test_sorting(self):
from pyanaconda.bootloader import Arguments
a = Arguments(["ip=eth0:dhcp", "rhgb", "quiet",
"root=/dev/mapper/destroyers-rubies", "rd.md=0",
"rd.luks=0"])
# 'rhgb quiet' should be the final entries:
assert(str(a).endswith("rhgb quiet"))