Merge lp:~abentley/charmworld/remove-redudant-id into lp:~juju-jitsu/charmworld/trunk

Proposed by Aaron Bentley
Status: Merged
Approved by: Aaron Bentley
Approved revision: 354
Merged at revision: 354
Proposed branch: lp:~abentley/charmworld/remove-redudant-id
Merge into: lp:~juju-jitsu/charmworld/trunk
Diff against target: 73 lines (+16/-15)
2 files modified
charmworld/jobs/ingest.py (+0/-7)
charmworld/jobs/tests/test_ingest.py (+16/-8)
To merge this branch: bzr merge lp:~abentley/charmworld/remove-redudant-id
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+180642@code.launchpad.net

Commit message

_id is not added to bundle's data attribute while ingesting.

Description of the change

Fix bug #1208481: bundles contain redundant _id in their data

Currently, _id is added to a bundle's data attribute, but this is wrong-- _id should be stored at the root level of the bundle, and already is. So this code can be deleted.

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

Thank you.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmworld/jobs/ingest.py'
2--- charmworld/jobs/ingest.py 2013-08-13 14:46:22 +0000
3+++ charmworld/jobs/ingest.py 2013-08-16 19:30:25 +0000
4@@ -298,12 +298,6 @@
5 data['name_revno'] = "%s/%d" % (data['name'], revno)
6 data['_id'] = '%s/%s' % (owner_segment, data['name_revno'])
7
8- @staticmethod
9- def decorate_bundles(basket_contents, basket_id):
10- # Give each bundle a unique ID.
11- for bundle_name, bundle in basket_contents.items():
12- bundle['_id'] = '%s/%s' % (basket_id, bundle_name)
13-
14 def decorate_basket(self, basket_data, fs):
15 branch_dir = fetch_branch(self.working_dir, basket_data, self.log)
16 branch = Branch.open(branch_dir)
17@@ -325,7 +319,6 @@
18 self.decorate_basket(basket_data, fs)
19 self.db.baskets.save(basket_data)
20 deployer_config = self.get_deployer_config(fs, basket_data)
21- self.decorate_bundles(deployer_config, basket_data['_id'])
22 self.store_bundles(
23 deployer_config, basket_data['owner'], basket_data['name_revno'])
24
25
26=== modified file 'charmworld/jobs/tests/test_ingest.py'
27--- charmworld/jobs/tests/test_ingest.py 2013-08-14 15:12:04 +0000
28+++ charmworld/jobs/tests/test_ingest.py 2013-08-16 19:30:25 +0000
29@@ -264,10 +264,10 @@
30 def test_run_updates_mongo(self):
31 # Running a bundle job creates a bundle document in mongo.
32 NAME = 'our-source-package'
33- bundle_data = factory.get_payload_json(name=NAME)
34+ basket_data = factory.get_payload_json(name=NAME)
35 with bundle_update_environment():
36- run_job(UpdateBundleJob(), bundle_data, db=self.db)
37- self.assertIsNotNone(self.db.baskets.find_one(bundle_data['_id']))
38+ run_job(UpdateBundleJob(), basket_data, db=self.db)
39+ self.assertIsNotNone(self.db.baskets.find_one(basket_data['_id']))
40
41 def test_run_creates_branch(self):
42 # The ingest job fetches the target branch.
43@@ -399,11 +399,6 @@
44 self.assertIsNot(None, bundles_hash)
45 self.assertEqual('{foo: {}}', fs.get(bundles_hash).read())
46
47- def test_decorate_bundles(self):
48- basket_contents = {'foo': {}}
49- UpdateBundleJob.decorate_bundles(basket_contents, '~bar/baz')
50- self.assertEqual({'foo': {'_id': '~bar/baz/foo'}}, basket_contents)
51-
52 def test_missing_revisions_generate_errors(self):
53 job = UpdateBundleJob()
54 job.setup(self.db)
55@@ -472,6 +467,19 @@
56 job.run(basket_data)
57 self.assertTrue(store_bundles.called)
58
59+ def test_job_run_does_not_alter_bundle_data(self):
60+ basket_data = factory.get_payload_json(name='wordpress')
61+ basket_data['name_revno'] = 'dummy'
62+ job = UpdateBundleJob()
63+ job.setup(self.db)
64+ with patch.object(job, 'get_deployer_config',
65+ side_effect=lambda x, y: {'foo': {}}):
66+ with patch.object(job, 'decorate_basket'):
67+ with patch.object(job, 'store_bundles') as store_bundles:
68+ job.run(basket_data)
69+ store_bundles.assert_called_with(
70+ {'foo': {}}, 'charmers', 'dummy')
71+
72
73 class TestUpdateCharm(MongoTestBase):
74

Subscribers

People subscribed via source and target branches