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
=== added file 'migrations/versions/005_no_op.py'
--- migrations/versions/005_no_op.py 1970-01-01 00:00:00 +0000
+++ migrations/versions/005_no_op.py 2013-06-04 18:24:39 +0000
@@ -0,0 +1,5 @@
1# Copyright 2013 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).
3
4def upgrade(db, index_client):
5 """005 failed to remove icons from charms, so now disabled."""
06
=== renamed file 'migrations/versions/005_delete_icon_field.py' => 'migrations/versions/006_delete_icon_field.py'
--- migrations/versions/005_delete_icon_field.py 2013-06-04 15:36:45 +0000
+++ migrations/versions/006_delete_icon_field.py 2013-06-04 18:24:39 +0000
@@ -4,5 +4,5 @@
44
55
6def upgrade(db, index_client):6def upgrade(db, index_client):
7 db.charms.update({}, {'$unset': {'icon':''}})7 db.charms.update({}, {'$unset': {'icon':''}}, multi=True)
8 reindex(index_client, list(db.charms.find({})))8 reindex(index_client, list(db.charms.find({})))
99
=== modified file 'migrations/versions/tests/test_migrations.py'
--- migrations/versions/tests/test_migrations.py 2013-06-04 15:36:45 +0000
+++ migrations/versions/tests/test_migrations.py 2013-06-04 18:24:39 +0000
@@ -66,12 +66,15 @@
66 self.assertNotIn('charm-errors', self.db.collection_names())66 self.assertNotIn('charm-errors', self.db.collection_names())
6767
6868
69class TestMigration005(MongoTestBase):69class TestMigration006(MongoTestBase):
7070
71 def test_migration(self):71 def test_migration(self):
72 self.use_index_client()72 self.use_index_client()
73 source = CharmSource.from_request(self)73 source = CharmSource.from_request(self)
74 source.save({'_id': 'a', 'icon': 'asdf', 'asdf': 'asdf'})74 source.save({'_id': 'a', 'icon': 'asdf', 'asdf': 'asdf'})
75 run_migration(self.db, self.index_client, '005_delete_icon_field.py')75 source.save({'_id': 'b', 'icon': 'asdf', 'asdf': 'asdf'})
76 run_migration(self.db, self.index_client, '006_delete_icon_field.py')
76 for charm in source._get_all('a'):77 for charm in source._get_all('a'):
77 self.assertNotIn('icon', charm)78 self.assertNotIn('icon', charm)
79 for charm in source._get_all('b'):
80 self.assertNotIn('icon', charm)

Subscribers

People subscribed via source and target branches