Merge lp:~bac/charmworld/bug-1234780 into lp:~juju-jitsu/charmworld/trunk

Proposed by Brad Crittenden
Status: Merged
Approved by: Brad Crittenden
Approved revision: 418
Merged at revision: 418
Proposed branch: lp:~bac/charmworld/bug-1234780
Merge into: lp:~juju-jitsu/charmworld/trunk
Diff against target: 73 lines (+32/-3)
3 files modified
charmworld/models.py (+5/-1)
charmworld/templates/bundle.pt (+4/-2)
charmworld/tests/test_models.py (+23/-0)
To merge this branch: bzr merge lp:~bac/charmworld/bug-1234780
Reviewer Review Type Date Requested Status
Juju Gui Bot continuous-integration Approve
Benji York (community) Approve
Review via email: mp+190676@code.launchpad.net

Commit message

Make bundle series a top-level property and allow it to be optional.

Description of the change

The page template for bundles was referencing bundle.data.series, which may not exist. It was the only reference to a non-property so I created a bundle.series property and return the value specified or None. The page template now displays the series conditionally.

Even when ingest proofs bundles, the series will remain optional, so this work will still be required.

To post a comment you must log in.
Revision history for this message
Benji York (benji) wrote :

Perfect in every way.

review: Approve
Revision history for this message
Juju Gui Bot (juju-gui-bot) wrote :

FAILED: Autolanding.
More details in the following jenkins job:
http://162.213.35.27:8080/job/charmworld-autoland-lxc/36/
Executed test runs:

review: Needs Fixing (continuous-integration)
Revision history for this message
Juju Gui Bot (juju-gui-bot) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'charmworld/models.py'
2--- charmworld/models.py 2013-10-10 15:24:30 +0000
3+++ charmworld/models.py 2013-10-11 14:05:35 +0000
4@@ -1303,7 +1303,7 @@
5 def __init__(self, data):
6 assert 'inherits' not in data, (
7 'inheriting from other bundles is not supported, the bundle '
8- 'must be preprocessed to incorporate any inheritance')
9+ 'must be pre-processed to incorporate any inheritance')
10 self._raw_representation = data
11 self._representation = dict(self._MONGO_FIELDS)
12 self._representation.update(data)
13@@ -1394,6 +1394,10 @@
14 """The short url for the basket branch on Launchpad."""
15 return 'https://code.launchpad.net/{}'.format(self._lp_path)
16
17+ @property
18+ def series(self):
19+ return self.data.get('series')
20+
21 @staticmethod
22 def getfs(db):
23 return getfs(db, collection='hashed-files')
24
25=== modified file 'charmworld/templates/bundle.pt'
26--- charmworld/templates/bundle.pt 2013-09-16 21:14:06 +0000
27+++ charmworld/templates/bundle.pt 2013-10-11 14:05:35 +0000
28@@ -40,8 +40,10 @@
29 <h4>Description</h4>
30 <p>${bundle.description}</p>
31 </metal:block>
32- <h4>Series</h4>
33- <p>${bundle.data.series}</p>
34+ <metal:series tal:condition="bundle.series">
35+ <h4>Series</h4>
36+ <p>${bundle.series}</p>
37+ </metal:series>
38 <h4>Owner</h4>
39 <p>${bundle.owner}</p>
40 <h4>Branch</h4>
41
42=== modified file 'charmworld/tests/test_models.py'
43--- charmworld/tests/test_models.py 2013-10-10 15:24:30 +0000
44+++ charmworld/tests/test_models.py 2013-10-11 14:05:35 +0000
45@@ -1943,6 +1943,29 @@
46 query = _build_charm_query_from_bundle_info(service_data, None)
47 self.assertIsNone(query)
48
49+ def test_uses_provided_series(self):
50+ """If a series is provided in the data, it is returned."""
51+ bundle = Bundle(
52+ {'name': 'tiny',
53+ 'owner': 'bac',
54+ 'basket_name': 'apache',
55+ 'basket_revision': 7,
56+ 'data': {'series': 'edgy'},
57+ })
58+ self.assertEqual(
59+ "edgy", bundle.series)
60+
61+ def test_default_series(self):
62+ """If no series is provided in the data, None is returned."""
63+ bundle = Bundle(
64+ {'name': 'tiny',
65+ 'owner': 'bac',
66+ 'basket_name': 'apache',
67+ 'basket_revision': 7,
68+ 'data': {},
69+ })
70+ self.assertIsNone(bundle.series)
71+
72
73 class TestMakeBundleDoc(TestCase):
74

Subscribers

People subscribed via source and target branches