Merge lp:~adam-collard/charms/trusty/apache2/apache2-charmhelpers-fix into lp:charms/trusty/apache2

Proposed by Adam Collard
Status: Merged
Approved by: David Britton
Approved revision: 64
Merged at revision: 64
Proposed branch: lp:~adam-collard/charms/trusty/apache2/apache2-charmhelpers-fix
Merge into: lp:charms/trusty/apache2
Diff against target: 33 lines (+14/-1)
2 files modified
hooks/hooks.py (+1/-1)
hooks/tests/test_config_changed.py (+13/-0)
To merge this branch: bzr merge lp:~adam-collard/charms/trusty/apache2/apache2-charmhelpers-fix
Reviewer Review Type Date Requested Status
David Britton (community) Approve
Review via email: mp+252497@code.launchpad.net

Description of the change

Fix the workaround in the Apache2 charm for an empty servername.

To post a comment you must log in.
Revision history for this message
David Britton (dpb) wrote :

Tested with landscape-dense-maas bundle (where problem was initially spotted), all is fine, verified unit test coverage.

Thanks for the change! looks great!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/hooks.py'
2--- hooks/hooks.py 2015-02-27 14:22:12 +0000
3+++ hooks/hooks.py 2015-03-10 19:17:23 +0000
4@@ -283,7 +283,7 @@
5 result = orig_config_get(scope)
6 if scope == "servername" and len(result) == 0:
7 result = unit_get("public-address")
8- elif type(result) is dict and result.get("servername", "") == "":
9+ elif isinstance(result, dict) and result.get("servername", "") == "":
10 result["servername"] = unit_get("public-address")
11 return result
12
13
14=== modified file 'hooks/tests/test_config_changed.py'
15--- hooks/tests/test_config_changed.py 2014-12-29 22:57:24 +0000
16+++ hooks/tests/test_config_changed.py 2015-03-10 19:17:23 +0000
17@@ -74,3 +74,16 @@
18 len(os.listdir("%s/%s" % (self.dirname, "sites-enabled"))), 0)
19 self.assertEqual(
20 len(os.listdir("%s/%s" % (self.dirname, "sites-available"))), 0)
21+
22+ @patch('hooks.orig_config_get')
23+ @patch('hooks.unit_get')
24+ def test_config_get_works_with_dict_subclass(
25+ self, mock_unit_get, mock_orig_config_get):
26+ """config_get() works with Charm Helper's custom dict subclass"""
27+ class FakeConfig(dict):
28+ pass
29+
30+ mock_orig_config_get.return_value = FakeConfig(servername="")
31+ mock_unit_get.return_value = "foo"
32+ config = hooks.config_get()
33+ self.assertEqual(config["servername"], "foo")

Subscribers

People subscribed via source and target branches

to all changes: