Merge lp:~benji/charmworld/bug-1229179 into lp:~juju-jitsu/charmworld/trunk

Proposed by Benji York
Status: Merged
Merged at revision: 432
Proposed branch: lp:~benji/charmworld/bug-1229179
Merge into: lp:~juju-jitsu/charmworld/trunk
Diff against target: 108 lines (+47/-4)
3 files modified
charmworld/routes.py (+4/-2)
charmworld/views/bundles.py (+3/-1)
charmworld/views/tests/test_bundles.py (+40/-1)
To merge this branch: bzr merge lp:~benji/charmworld/bug-1229179
Reviewer Review Type Date Requested Status
Juju-Jitsu Hackers Pending
Review via email: mp+193131@code.launchpad.net

Description of the change

To post a comment you must log in.
Revision history for this message
Brad Crittenden (bac) wrote :

LGTM, yo.

https://codereview.appspot.com/19430043/diff/1/charmworld/views/tests/test_bundles.py
File charmworld/views/tests/test_bundles.py (right):

https://codereview.appspot.com/19430043/diff/1/charmworld/views/tests/test_bundles.py#newcode228
charmworld/views/tests/test_bundles.py:228: self.db, name='gigis',
owner='ladonna',
bonus points for identifying the reference here.

https://codereview.appspot.com/19430043/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'charmworld/routes.py'
--- charmworld/routes.py 2013-10-02 15:33:27 +0000
+++ charmworld/routes.py 2013-10-29 20:19:29 +0000
@@ -53,12 +53,14 @@
53 config.add_route("interface-collection-map", "/interface-charm-map")53 config.add_route("interface-collection-map", "/interface-charm-map")
5454
55 # Personal Bundles55 # Personal Bundles
56 config.add_route("personal-bundle-json-revision",
57 "/~{owner}/bundle/{basket}/{rev}/{bundle}/json")
58 config.add_route("personal-bundle-json",
59 "/~{owner}/bundle/{basket}/{bundle}/json")
56 config.add_route("personal-bundle-revision",60 config.add_route("personal-bundle-revision",
57 "/~{owner}/bundle/{basket}/{rev}/{bundle}")61 "/~{owner}/bundle/{basket}/{rev}/{bundle}")
58 config.add_route("personal-bundle",62 config.add_route("personal-bundle",
59 "/~{owner}/bundle/{basket}/{bundle}")63 "/~{owner}/bundle/{basket}/{bundle}")
60 config.add_route("personal-bundle-json",
61 "/~{owner}/bundle/{basket}/{rev}/{bundle}/json")
6264
63 # Official (promulgated) Bundles65 # Official (promulgated) Bundles
64 config.add_route("official-bundle-json",66 config.add_route("official-bundle-json",
6567
=== modified file 'charmworld/views/bundles.py'
--- charmworld/views/bundles.py 2013-10-24 17:24:43 +0000
+++ charmworld/views/bundles.py 2013-10-29 20:19:29 +0000
@@ -122,6 +122,8 @@
122122
123123
124@cached_view_config(124@cached_view_config(
125 route_name="personal-bundle-json-revision")
126@cached_view_config(
125 route_name="personal-bundle-json")127 route_name="personal-bundle-json")
126def personal_bundle_json(request):128def personal_bundle_json(request):
127 bundle = find_bundle(request)129 bundle = find_bundle(request)
@@ -131,7 +133,7 @@
131 request.matchdict['owner'],133 request.matchdict['owner'],
132 request.matchdict['basket'],134 request.matchdict['basket'],
133 request.matchdict['bundle'],135 request.matchdict['bundle'],
134 request.matchdict['rev']136 request.matchdict.get('rev'),
135 )137 )
136 value = {'type': 'no_such_bundle', 'bundle_id': id_}138 value = {'type': 'no_such_bundle', 'bundle_id': id_}
137 else:139 else:
138140
=== modified file 'charmworld/views/tests/test_bundles.py'
--- charmworld/views/tests/test_bundles.py 2013-10-10 20:02:51 +0000
+++ charmworld/views/tests/test_bundles.py 2013-10-29 20:19:29 +0000
@@ -221,6 +221,30 @@
221 self.assertEqual(response.status_code, 200)221 self.assertEqual(response.status_code, 200)
222 self.assertEqual(expected, response.json_body)222 self.assertEqual(expected, response.json_body)
223223
224 def test_personal_bundle_json_with_revision(self):
225 basket = 'ball'
226 rev = '4'
227 bundle, bundle_data = factory.makeBundle(
228 self.db, name='gigis', owner='ladonna',
229 basket_with_rev='/'.join([basket, rev]),
230 series='raring', promulgated=False,
231 )
232 request = self.getRequest()
233 request.matchdict = dict(
234 owner=bundle.owner,
235 basket=basket,
236 rev=None,
237 bundle=bundle.name,
238 )
239 expected = {'gigis': dict(
240 series='raring',
241 relations={},
242 services={},
243 )}
244 response = personal_bundle_json(request)
245 self.assertEqual(response.status_code, 200)
246 self.assertEqual(expected, response.json_body)
247
224 def test_personal_bundle_json_not_found(self):248 def test_personal_bundle_json_not_found(self):
225 owner = 'no-one'249 owner = 'no-one'
226 basket = 'no-basket'250 basket = 'no-basket'
@@ -321,7 +345,9 @@
321 path = '/~ladonna/bundle/basket/1/XXX'345 path = '/~ladonna/bundle/basket/1/XXX'
322 self.app.get(path, status=404)346 self.app.get(path, status=404)
323347
324 def test_personal_bundle_json_route(self):348 def test_personal_bundle_with_revision_json_route(self):
349 # A JSON-encoded bundle can be requested in which the ID includes both
350 # an owner and a revision.
325 bundle, bundle_data = factory.makeBundle(351 bundle, bundle_data = factory.makeBundle(
326 self.db, name='gigis', owner='ladonna',352 self.db, name='gigis', owner='ladonna',
327 basket_with_rev='basket/1', series='raring',353 basket_with_rev='basket/1', series='raring',
@@ -332,6 +358,19 @@
332 self.assertIn(str(bundle.data['relations']), resp.body)358 self.assertIn(str(bundle.data['relations']), resp.body)
333 self.assertIn(str(bundle.data['services']), resp.body)359 self.assertIn(str(bundle.data['services']), resp.body)
334360
361 def test_personal_bundle_without_revision_json_route(self):
362 # A JSON-encoded bundle can be requested in which the ID includes an
363 # owner but no revision.
364 bundle, bundle_data = factory.makeBundle(
365 self.db, name='gigis', owner='lafawnda',
366 basket_with_rev='basket/1', series='raring',
367 )
368 path = '/~lafawnda/bundle/basket/gigis/json'
369 resp = self.app.get(path, status=200)
370 self.assertIn(bundle.data['series'], resp.body)
371 self.assertIn(str(bundle.data['relations']), resp.body)
372 self.assertIn(str(bundle.data['services']), resp.body)
373
335 def test_personal_bundle_json_route_404(self):374 def test_personal_bundle_json_route_404(self):
336 bundle, bundle_data = factory.makeBundle(375 bundle, bundle_data = factory.makeBundle(
337 self.db, name='gigis', owner='ladonna',376 self.db, name='gigis', owner='ladonna',

Subscribers

People subscribed via source and target branches