Merge lp:~barry/ubuntu-system-image/lp1455119 into lp:ubuntu-system-image/server

Proposed by Barry Warsaw
Status: Merged
Merged at revision: 267
Proposed branch: lp:~barry/ubuntu-system-image/lp1455119
Merge into: lp:ubuntu-system-image/server
Diff against target: 70 lines (+30/-1)
3 files modified
bin/copy-image (+1/-1)
lib/systemimage/tests/test_tree.py (+28/-0)
lib/systemimage/tree.py (+1/-0)
To merge this branch: bzr merge lp:~barry/ubuntu-system-image/lp1455119
Reviewer Review Type Date Requested Status
Steve Langasek Pending
Review via email: mp+259168@code.launchpad.net

Description of the change

Ignores redirects in the calculation and generation of alias channels.

(Drive-by fix of obvious typo in copy-image logging.)

To post a comment you must log in.
Revision history for this message
Barry Warsaw (barry) :
268. By Barry Warsaw

Add a unittest for the channel-is-a-redirect-and-alias bug. LP: #1455119

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/copy-image'
2--- bin/copy-image 2015-04-20 18:33:10 +0000
3+++ bin/copy-image 2015-05-14 22:33:40 +0000
4@@ -222,7 +222,7 @@
5 environment['new_files'] = new_images['full']['files']
6
7 logging.info("Generating new version tarball for '%s' (%s)"
8- % (new_version, "," % environment['version_detail']))
9+ % (new_version, ",".join(environment['version_detail'])))
10 version_path = generators.generate_file(conf, "version", [], environment)
11 if version_path:
12 new_images['full']['files'].append(version_path)
13
14=== modified file 'lib/systemimage/tests/test_tree.py'
15--- lib/systemimage/tests/test_tree.py 2015-02-24 18:17:26 +0000
16+++ lib/systemimage/tests/test_tree.py 2015-05-14 22:33:40 +0000
17@@ -24,6 +24,11 @@
18 from systemimage import config, gpg, tree, tools
19 from systemimage.testing.helpers import HAS_TEST_KEYS, MISSING_KEYS_WARNING
20
21+try:
22+ from unittest.mock import patch
23+except ImportError:
24+ from mock import patch
25+
26
27 class TreeTests(unittest.TestCase):
28 def setUp(self):
29@@ -384,6 +389,29 @@
30 self.assertEqual(device.list_images(), target.list_images())
31
32 @unittest.skipUnless(HAS_TEST_KEYS, MISSING_KEYS_WARNING)
33+ def test_redirect_alias(self):
34+ # LP: #1455119 - a channel which is both an alias and a redirect is
35+ # culled from sync_aliases().
36+ test_tree = tree.Tree(self.config)
37+
38+ # Create some channels and aliases
39+ test_tree.create_channel("parent")
40+ test_tree.create_channel("overthere")
41+ test_tree.create_channel_redirect("redirect", "overthere")
42+
43+ # Make the overthere channel both an alias and a redirect
44+ with tree.channels_json(test_tree.config,
45+ test_tree.indexpath, True) as channels:
46+ channel = channels["overthere"]
47+ channel["alias"] = "redirect"
48+ channel["redirect"] = "overthere"
49+
50+ # No sync_alias() call should be made on the this channel.
51+ with patch.object(test_tree, 'sync_alias') as mock:
52+ test_tree.sync_aliases("redirect")
53+ self.assertFalse(mock.called)
54+
55+ @unittest.skipUnless(HAS_TEST_KEYS, MISSING_KEYS_WARNING)
56 def test_rename(self):
57 test_tree = tree.Tree(self.config)
58
59
60=== modified file 'lib/systemimage/tree.py'
61--- lib/systemimage/tree.py 2015-04-10 17:35:24 +0000
62+++ lib/systemimage/tree.py 2015-05-14 22:33:40 +0000
63@@ -776,6 +776,7 @@
64 for name, channel
65 in self.list_channels().items()
66 if channel.get("alias", None) == channel_name
67+ and channel.get("redirect", None) is None
68 and name != channel_name]
69
70 for alias_name in alias_channels:

Subscribers

People subscribed via source and target branches

to all changes: