Merge lp:~abentley/charmworld/really-remove-icon into lp:~juju-jitsu/charmworld/trunk

Proposed by Aaron Bentley
Status: Merged
Approved by: Curtis Hovey
Approved revision: 244
Merged at revision: 244
Proposed branch: lp:~abentley/charmworld/really-remove-icon
Merge into: lp:~juju-jitsu/charmworld/trunk
Diff against target: 42 lines (+11/-3)
3 files modified
migrations/versions/005_no_op.py (+5/-0)
migrations/versions/006_delete_icon_field.py (+1/-1)
migrations/versions/tests/test_migrations.py (+5/-2)
To merge this branch: bzr merge lp:~abentley/charmworld/really-remove-icon
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+167364@code.launchpad.net

Commit message

Fix icon deletion, make version number 6.

Description of the change

The previous attempt to delete icons from the charm docs lacked the crucial multi flag, so it migrated only one document. This version, migration version 6, deletes all icons.

To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :

Thank you. The multi=True option is a bit like the g/global option in RE that trips me up when doing substitutions.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'migrations/versions/005_no_op.py'
2--- migrations/versions/005_no_op.py 1970-01-01 00:00:00 +0000
3+++ migrations/versions/005_no_op.py 2013-06-04 18:24:39 +0000
4@@ -0,0 +1,5 @@
5+# Copyright 2013 Canonical Ltd. This software is licensed under the
6+# GNU Affero General Public License version 3 (see the file LICENSE).
7+
8+def upgrade(db, index_client):
9+ """005 failed to remove icons from charms, so now disabled."""
10
11=== renamed file 'migrations/versions/005_delete_icon_field.py' => 'migrations/versions/006_delete_icon_field.py'
12--- migrations/versions/005_delete_icon_field.py 2013-06-04 15:36:45 +0000
13+++ migrations/versions/006_delete_icon_field.py 2013-06-04 18:24:39 +0000
14@@ -4,5 +4,5 @@
15
16
17 def upgrade(db, index_client):
18- db.charms.update({}, {'$unset': {'icon':''}})
19+ db.charms.update({}, {'$unset': {'icon':''}}, multi=True)
20 reindex(index_client, list(db.charms.find({})))
21
22=== modified file 'migrations/versions/tests/test_migrations.py'
23--- migrations/versions/tests/test_migrations.py 2013-06-04 15:36:45 +0000
24+++ migrations/versions/tests/test_migrations.py 2013-06-04 18:24:39 +0000
25@@ -66,12 +66,15 @@
26 self.assertNotIn('charm-errors', self.db.collection_names())
27
28
29-class TestMigration005(MongoTestBase):
30+class TestMigration006(MongoTestBase):
31
32 def test_migration(self):
33 self.use_index_client()
34 source = CharmSource.from_request(self)
35 source.save({'_id': 'a', 'icon': 'asdf', 'asdf': 'asdf'})
36- run_migration(self.db, self.index_client, '005_delete_icon_field.py')
37+ source.save({'_id': 'b', 'icon': 'asdf', 'asdf': 'asdf'})
38+ run_migration(self.db, self.index_client, '006_delete_icon_field.py')
39 for charm in source._get_all('a'):
40 self.assertNotIn('icon', charm)
41+ for charm in source._get_all('b'):
42+ self.assertNotIn('icon', charm)

Subscribers

People subscribed via source and target branches