Merge lp:~dpb/juju-deployer/empty-options-1361883 into lp:juju-deployer

Proposed by David Britton
Status: Merged
Merged at revision: 121
Proposed branch: lp:~dpb/juju-deployer/empty-options-1361883
Merge into: lp:juju-deployer
Diff against target: 72 lines (+35/-1)
5 files modified
Makefile (+2/-0)
deployer/deployment.py (+4/-1)
deployer/tests/test_data/negative.cfg (+10/-0)
deployer/tests/test_data/negative.yaml (+5/-0)
deployer/tests/test_deployment.py (+14/-0)
To merge this branch: bzr merge lp:~dpb/juju-deployer/empty-options-1361883
Reviewer Review Type Date Requested Status
Kapil Thangavelu Approve
Review via email: mp+232332@code.launchpad.net

Description of the change

Simple none type check to fix. test cases fail if you revert the patch to deployment.py

To post a comment you must log in.
Revision history for this message
Kapil Thangavelu (hazmat) wrote :

thanks, fwiw for test running i typically just do python setup.py test

Revision history for this message
Kapil Thangavelu (hazmat) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Makefile'
--- Makefile 2014-02-22 23:33:57 +0000
+++ Makefile 2014-08-26 22:36:31 +0000
@@ -1,3 +1,5 @@
1test:
2 nosetests -s --verbosity=2 deployer/tests
13
2freeze:4freeze:
3 pip install -d tools/dist -r requirements.txt5 pip install -d tools/dist -r requirements.txt
46
=== modified file 'deployer/deployment.py'
--- deployer/deployment.py 2014-04-21 22:49:05 +0000
+++ deployer/deployment.py 2014-08-26 22:36:31 +0000
@@ -183,7 +183,10 @@
183 config = charm.config183 config = charm.config
184 options = {}184 options = {}
185185
186 for k, v in svc_data['options'].items():186 svc_options = svc_data.get('options', {})
187 if svc_options is None:
188 svc_options = {}
189 for k, v in svc_options.items():
187 if not k in config:190 if not k in config:
188 feedback.error(191 feedback.error(
189 "Invalid config charm %s %s=%s" % (charm.name, k, v))192 "Invalid config charm %s %s=%s" % (charm.name, k, v))
190193
=== added file 'deployer/tests/test_data/negative.cfg'
--- deployer/tests/test_data/negative.cfg 1970-01-01 00:00:00 +0000
+++ deployer/tests/test_data/negative.cfg 2014-08-26 22:36:31 +0000
@@ -0,0 +1,10 @@
1{
2 "negative": {
3 "services": {
4 "foo": {
5 # lp:1361883
6 "options": {}
7 }
8 }
9 }
10}
011
=== added file 'deployer/tests/test_data/negative.yaml'
--- deployer/tests/test_data/negative.yaml 1970-01-01 00:00:00 +0000
+++ deployer/tests/test_data/negative.yaml 2014-08-26 22:36:31 +0000
@@ -0,0 +1,5 @@
1negative:
2 services:
3 foo:
4 options:
5 # lp:1361883
06
=== modified file 'deployer/tests/test_deployment.py'
--- deployer/tests/test_deployment.py 2014-02-18 14:33:13 +0000
+++ deployer/tests/test_deployment.py 2014-08-26 22:36:31 +0000
@@ -156,3 +156,17 @@
156 expected_service_names = [156 expected_service_names = [
157 'ceph', 'mysql', 'nova-compute', 'quantum', 'semper', 'verity']157 'ceph', 'mysql', 'nova-compute', 'quantum', 'semper', 'verity']
158 self.assertEqual(set(expected_service_names), set(service_names))158 self.assertEqual(set(expected_service_names), set(service_names))
159
160 def test_resolve_config_handles_empty_options(self):
161 """resolve_config should handle options being "empty" lp:1361883"""
162 deployment = self.get_named_deployment("negative.cfg", "negative")
163 self.assertEqual(
164 deployment.data["services"]["foo"]["options"], {})
165 deployment.resolve_config()
166
167 def test_resolve_config_handles_none_options(self):
168 """resolve_config should handle options being "none" lp:1361883"""
169 deployment = self.get_named_deployment("negative.yaml", "negative")
170 self.assertEqual(
171 deployment.data["services"]["foo"]["options"], None)
172 deployment.resolve_config()

Subscribers

People subscribed via source and target branches