Merge lp:~abentley/charmworld/config-storage-2 into lp:~juju-jitsu/charmworld/trunk

Proposed by Aaron Bentley
Status: Merged
Approved by: Curtis Hovey
Approved revision: 300
Merged at revision: 301
Proposed branch: lp:~abentley/charmworld/config-storage-2
Merge into: lp:~juju-jitsu/charmworld/trunk
Diff against target: 26 lines (+5/-0)
2 files modified
charmworld/models.py (+2/-0)
charmworld/tests/test_models.py (+3/-0)
To merge this branch: bzr merge lp:~abentley/charmworld/config-storage-2
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+173757@code.launchpad.net

Commit message

Handle None in options_to_storage.

Description of the change

Some charms have options set to null rather than an object. This branch allows them to be processed by interpreting None as an empty dict.

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/models.py'
2--- charmworld/models.py 2013-07-09 15:31:40 +0000
3+++ charmworld/models.py 2013-07-09 15:37:30 +0000
4@@ -1107,6 +1107,8 @@
5 elasticsearch.
6 """
7 storage = []
8+ if options is None:
9+ return storage
10 for key, value in options.items():
11 option = {'name': key}
12 option.update(value)
13
14=== added file 'charmworld/tests/__init__.py'
15=== modified file 'charmworld/tests/test_models.py'
16--- charmworld/tests/test_models.py 2013-07-09 15:31:40 +0000
17+++ charmworld/tests/test_models.py 2013-07-09 15:37:30 +0000
18@@ -1094,6 +1094,9 @@
19 def test_options_to_storage(self):
20 self.assertItemsEqual(self.storage, options_to_storage(self.yaml))
21
22+ def test_options_to_storage_none(self):
23+ self.assertItemsEqual([], options_to_storage(None))
24+
25 def test_storage_to_options(self):
26 self.assertEqual(self.yaml, storage_to_options(self.storage))
27

Subscribers

People subscribed via source and target branches