summaryrefslogtreecommitdiff
path: root/debian/patches/cpick-8c6878a-tests-fix-assumptions-that-expected-no-eth0-in-system
blob: 2ec382179b7211b1e673ff152b28dd8edb54da0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
commit 8c6878a04eff2fd75115b5f23faa2665cabb5ccd
Author: Scott Moser <smoser@brickies.net>
Date:   Tue Nov 22 22:49:07 2016 -0500

    tests: fix assumptions that expected no eth0 in system.
    
    The previous commit added tests that would fail on any system that had
    a nic named eth0 or eno1. The changes here supply the expected macs to
    the function being tested so it does not query the system.
    
    LP: #1644043

--- a/tests/unittests/test_net.py
+++ b/tests/unittests/test_net.py
@@ -662,25 +662,34 @@ class TestCmdlineConfigParsing(TestCase)
 
 
 class TestCmdlineReadKernelConfig(TempDirTestCase):
+    macs = {
+        'eth0': '14:02:ec:42:48:00',
+        'eno1': '14:02:ec:42:48:01',
+    }
+
     def test_ip_cmdline_read_kernel_cmdline_ip(self):
         content = {'net-eth0.conf': DHCP_CONTENT_1}
         populate_dir(self.tmp, content)
         files = [os.path.join(self.tmp, k) for k in content.keys()]
         found = cmdline.read_kernel_cmdline_config(
-            files=files, cmdline='foo ip=dhcp')
+            files=files, cmdline='foo ip=dhcp', mac_addrs=self.macs)
+        exp1 = copy.deepcopy(DHCP_EXPECTED_1)
+        exp1['mac_address'] = self.macs['eth0']
         self.assertEqual(found['version'], 1)
-        self.assertEqual(found['config'], [DHCP_EXPECTED_1])
+        self.assertEqual(found['config'], [exp1])
 
     def test_ip_cmdline_read_kernel_cmdline_ip6(self):
         content = {'net6-eno1.conf': DHCP6_CONTENT_1}
         populate_dir(self.tmp, content)
         files = [os.path.join(self.tmp, k) for k in content.keys()]
         found = cmdline.read_kernel_cmdline_config(
-            files=files, cmdline='foo ip6=dhcp root=/dev/sda')
+            files=files, cmdline='foo ip6=dhcp root=/dev/sda',
+            mac_addrs=self.macs)
         self.assertEqual(
             found,
             {'version': 1, 'config': [
              {'type': 'physical', 'name': 'eno1',
+              'mac_address': self.macs['eno1'],
               'subnets': [
                   {'dns_nameservers': ['2001:67c:1562:8010::2:1'],
                    'control': 'manual', 'type': 'dhcp6', 'netmask': '64'}]}]})
@@ -691,7 +700,7 @@ class TestCmdlineReadKernelConfig(TempDi
         populate_dir(self.tmp, content)
         files = [os.path.join(self.tmp, k) for k in content.keys()]
         found = cmdline.read_kernel_cmdline_config(
-            files=files, cmdline='foo root=/dev/sda')
+            files=files, cmdline='foo root=/dev/sda', mac_addrs=self.macs)
         self.assertEqual(found, None)
 
     def test_ip_cmdline_both_ip_ip6(self):
@@ -700,9 +709,10 @@ class TestCmdlineReadKernelConfig(TempDi
         populate_dir(self.tmp, content)
         files = [os.path.join(self.tmp, k) for k in sorted(content.keys())]
         found = cmdline.read_kernel_cmdline_config(
-            files=files, cmdline='foo ip=dhcp ip6=dhcp')
+            files=files, cmdline='foo ip=dhcp ip6=dhcp', mac_addrs=self.macs)
 
         eth0 = copy.deepcopy(DHCP_EXPECTED_1)
+        eth0['mac_address'] = self.macs['eth0']
         eth0['subnets'].append(
             {'control': 'manual', 'type': 'dhcp6',
              'netmask': '64', 'dns_nameservers': ['2001:67c:1562:8010::2:1']})