def set(self, args):
diff --git a/tests/booty_test/bootloaderInfo_test.py b/tests/booty_test/bootloaderInfo_test.py
new file mode 100644
index 0000000..fe057a8
--- /dev/null
+++ b/tests/booty_test/bootloaderInfo_test.py
@@ -0,0 +1,28 @@
+import mock
+
+class KernelArgumentsTestCase(mock.TestCase):
+ def setUp(self):
+ self.setupModules(
+ ['_isys', 'logging', 'anaconda_log', 'block'])
+
+ def tearDown(self):
+ self.tearDownModules()
+
+ def test_merge_ip(self):
+ import booty
+ ka = booty.KernelArguments(mock.Mock())
+
+ # test that _merge_ip() doesnt break the simple case:
+ args = set(["one", "two", "ip=eth0:dhcp"])
+ self.assertEqual(ka._merge_ip(args),
+ set(["one", "two", "ip=eth0:dhcp"]))
+
+ # test that it does what it's supposed to:
+ args = set(["one", "two", "ip=eth0:dhcp", "ip=eth0:auto6",
+ "ip=wlan0:dhcp",
+ "ip=10.34.102.102::10.34.39.255:24:aklab:eth2:none "])
+ self.assertEqual(ka._merge_ip(args), set([
+ "one", "two",
+ "ip=wlan0:dhcp",
+ "ip=10.34.102.102::10.34.39.255:24:aklab:eth2:none ",
+ "ip=eth0:auto6,dhcp"]))
--
1.7.6
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
09-26-2011, 01:01 PM
Ales Kozumplik
grub: write 'ip=eth0:dhcp, auto6' instead of 'ip=eth0:dhcp ip=eth0:auto6'
On 09/26/2011 02:26 PM, Martin Gracik wrote:
I don't see any errors in here, but it took me a while to wrap my brain
around it. I think in this particular case you would be better of with
list comprehensions instead of map.
Thats why I used the map to make the extracting steps evident. I am not
going to take over your entire function just some bits of it which I
find most useful.
# create mapping from nics to their configurations
config = collections.defaultdict(list)
for nic, cfg in ip_params:
config[nic].append(cfg)
This is a really cute idiom I wasn't aware of. We can use this in tens
of places.
I use set() on ip_params in the beginning to make sure we don't have
more of the same arguments, if this can happen here...
The passed in argument is a set already.
Also, as I see it, you don't need to strip the "ip=" because all the
parameters in that list have it, and later you are prepending it again
to all members.
Good point, this saves some lines and makes it look simpler.
So you can take this as an ACK to your solution, and this is just my
suggestion to make the function a little bit simpler.
I'll push it with the tweaks suggested in your solution.
Thanks for taking the time to inspect this in so much detail.
Ales
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list