~smoser/curtin/trunk.lp1684128

« back to all changes in this revision

Viewing changes to tests/vmtests/test_old_apt_features.py

  • Committer: Josh Powers
  • Date: 2017-04-13 21:18:28 UTC
  • mfrom: (486.1.3 fix-noapt-test)
  • Revision ID: josh.powers@canonical.com-20170413211828-mewztalt42ftvdtt
vmtest: update source.list test

The change that was made to the builtin /etc/apt/sources.list in the
cloud images for xenial was done so recently under bug LP: #1513529.
That was by design and required for consistency and this change updates
the curtin vmtest accordingly.

LP: #1682516

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
from curtin import util
11
11
 
12
12
 
 
13
def sources_to_dict(lines):
 
14
    # read a sources.list file, return a dictionary like
 
15
    #  {'mirror1': {'suite1': [comp1, comp2], 'suite2': [comp3]}
 
16
    #   'mirror2': {'xenial': [main, universe, multiverse]}}
 
17
    found = {}
 
18
    for line in lines:
 
19
        try:
 
20
            toks = line.split()
 
21
            deb, mirror, suite = toks[0:3]
 
22
            components = toks[3:]
 
23
        except ValueError:
 
24
            continue
 
25
        if deb != "deb":
 
26
            continue
 
27
        if mirror not in found:
 
28
            found[mirror] = {}
 
29
        if suite not in found[mirror]:
 
30
            found[mirror][suite] = []
 
31
 
 
32
        found[mirror][suite].extend(components)
 
33
    return found
 
34
 
 
35
 
13
36
class TestOldAptAbs(VMBaseClass):
14
37
    """TestOldAptAbs - Basic tests for old apt features of curtin"""
15
38
    interactive = False
66
89
 
67
90
    def test_mirrors(self):
68
91
        """test_mirrors - Check for mirrors placed in source.list"""
 
92
        lines = self.load_collect_file('sources.list').splitlines()
 
93
        data = sources_to_dict(lines)
 
94
        self.assertIn(self.exp_secmirror, data)
 
95
        self.assertIn(self.exp_mirror, data)
69
96
 
70
 
        self.check_file_strippedline("sources.list",
71
 
                                     "deb %s %s" %
72
 
                                     (self.exp_mirror, self.release) +
73
 
                                     " main restricted universe multiverse")
74
 
        self.check_file_strippedline("sources.list",
75
 
                                     "deb %s %s-security" %
76
 
                                     (self.exp_secmirror, self.release) +
77
 
                                     " main restricted universe multiverse")
 
97
        components = sorted(["main", "restricted", "universe", "multiverse"])
 
98
        self.assertEqual(
 
99
            components,
 
100
            sorted(data[self.exp_secmirror]['%s-security' % self.release]))
 
101
        self.assertEqual(components,
 
102
                         sorted(data[self.exp_mirror][self.release]))
78
103
 
79
104
    def test_cloudinit_seeded(self):
80
105
        content = self.load_collect_file("90_dpkg.cfg")