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.
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
1=== modified file 'charmworld/routes.py'
2--- charmworld/routes.py 2013-10-02 15:33:27 +0000
3+++ charmworld/routes.py 2013-10-29 20:19:29 +0000
4@@ -53,12 +53,14 @@
5 config.add_route("interface-collection-map", "/interface-charm-map")
6
7 # Personal Bundles
8+ config.add_route("personal-bundle-json-revision",
9+ "/~{owner}/bundle/{basket}/{rev}/{bundle}/json")
10+ config.add_route("personal-bundle-json",
11+ "/~{owner}/bundle/{basket}/{bundle}/json")
12 config.add_route("personal-bundle-revision",
13 "/~{owner}/bundle/{basket}/{rev}/{bundle}")
14 config.add_route("personal-bundle",
15 "/~{owner}/bundle/{basket}/{bundle}")
16- config.add_route("personal-bundle-json",
17- "/~{owner}/bundle/{basket}/{rev}/{bundle}/json")
18
19 # Official (promulgated) Bundles
20 config.add_route("official-bundle-json",
21
22=== modified file 'charmworld/views/bundles.py'
23--- charmworld/views/bundles.py 2013-10-24 17:24:43 +0000
24+++ charmworld/views/bundles.py 2013-10-29 20:19:29 +0000
25@@ -122,6 +122,8 @@
26
27
28 @cached_view_config(
29+ route_name="personal-bundle-json-revision")
30+@cached_view_config(
31 route_name="personal-bundle-json")
32 def personal_bundle_json(request):
33 bundle = find_bundle(request)
34@@ -131,7 +133,7 @@
35 request.matchdict['owner'],
36 request.matchdict['basket'],
37 request.matchdict['bundle'],
38- request.matchdict['rev']
39+ request.matchdict.get('rev'),
40 )
41 value = {'type': 'no_such_bundle', 'bundle_id': id_}
42 else:
43
44=== modified file 'charmworld/views/tests/test_bundles.py'
45--- charmworld/views/tests/test_bundles.py 2013-10-10 20:02:51 +0000
46+++ charmworld/views/tests/test_bundles.py 2013-10-29 20:19:29 +0000
47@@ -221,6 +221,30 @@
48 self.assertEqual(response.status_code, 200)
49 self.assertEqual(expected, response.json_body)
50
51+ def test_personal_bundle_json_with_revision(self):
52+ basket = 'ball'
53+ rev = '4'
54+ bundle, bundle_data = factory.makeBundle(
55+ self.db, name='gigis', owner='ladonna',
56+ basket_with_rev='/'.join([basket, rev]),
57+ series='raring', promulgated=False,
58+ )
59+ request = self.getRequest()
60+ request.matchdict = dict(
61+ owner=bundle.owner,
62+ basket=basket,
63+ rev=None,
64+ bundle=bundle.name,
65+ )
66+ expected = {'gigis': dict(
67+ series='raring',
68+ relations={},
69+ services={},
70+ )}
71+ response = personal_bundle_json(request)
72+ self.assertEqual(response.status_code, 200)
73+ self.assertEqual(expected, response.json_body)
74+
75 def test_personal_bundle_json_not_found(self):
76 owner = 'no-one'
77 basket = 'no-basket'
78@@ -321,7 +345,9 @@
79 path = '/~ladonna/bundle/basket/1/XXX'
80 self.app.get(path, status=404)
81
82- def test_personal_bundle_json_route(self):
83+ def test_personal_bundle_with_revision_json_route(self):
84+ # A JSON-encoded bundle can be requested in which the ID includes both
85+ # an owner and a revision.
86 bundle, bundle_data = factory.makeBundle(
87 self.db, name='gigis', owner='ladonna',
88 basket_with_rev='basket/1', series='raring',
89@@ -332,6 +358,19 @@
90 self.assertIn(str(bundle.data['relations']), resp.body)
91 self.assertIn(str(bundle.data['services']), resp.body)
92
93+ def test_personal_bundle_without_revision_json_route(self):
94+ # A JSON-encoded bundle can be requested in which the ID includes an
95+ # owner but no revision.
96+ bundle, bundle_data = factory.makeBundle(
97+ self.db, name='gigis', owner='lafawnda',
98+ basket_with_rev='basket/1', series='raring',
99+ )
100+ path = '/~lafawnda/bundle/basket/gigis/json'
101+ resp = self.app.get(path, status=200)
102+ self.assertIn(bundle.data['series'], resp.body)
103+ self.assertIn(str(bundle.data['relations']), resp.body)
104+ self.assertIn(str(bundle.data['services']), resp.body)
105+
106 def test_personal_bundle_json_route_404(self):
107 bundle, bundle_data = factory.makeBundle(
108 self.db, name='gigis', owner='ladonna',

Subscribers

People subscribed via source and target branches