Merge lp:~jimbaker/pyjuju/relation-ids-whitespace-separated into lp:pyjuju
Proposed by
Jim Baker
Status: | Merged |
---|---|
Merged at revision: | 532 |
Proposed branch: | lp:~jimbaker/pyjuju/relation-ids-whitespace-separated |
Merge into: | lp:pyjuju |
Diff against target: |
53 lines (+31/-1) 2 files modified
juju/hooks/commands.py (+4/-0) juju/hooks/tests/test_invoker.py (+27/-1) |
To merge this branch: | bzr merge lp:~jimbaker/pyjuju/relation-ids-whitespace-separated |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+103387@code.launchpad.net |
Description of the change
Support smart formatting for relation-ids command
Adds format_smart method for RelationIdsCli, which outputs whitespace separated (to be precise, per line) relation idents.
To post a comment you must log in.
Reviewers: mp+103387_ code.launchpad. net,
Message:
Please take a look.
Description:
Support smart formatting for relation-ids command
Adds format_smart method for RelationIdsCli, which outputs whitespace
separated (to be precise, per line) relation idents.
https:/ /code.launchpad .net/~jimbaker/ juju/relation- ids-whitespace- separated/ +merge/ 103387
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/6118047/
Affected files: commands. py tests/test_ invoker. py
A [revision details]
M juju/hooks/
M juju/hooks/
Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision:
<email address hidden>
+New revision: <email address hidden>
Index: juju/hooks/ commands. py commands. py' commands. py 2012-04-10 16:42:18 +0000 commands. py 2012-04-24 21:47:40 +0000
self.options. client_ id, self.options. relation_ name)
returnValue( result)
=== modified file 'juju/hooks/
--- juju/hooks/
+++ juju/hooks/
@@ -117,6 +117,10 @@
+ def format_smart(self, result, stream):
+ for ident in result:
+ print >>stream, ident
+
def relation_ids():
"""Entry point for relation-set."""
Index: juju/hooks/ tests/test_ invoker. py tests/test_ invoker. py' tests/test_ invoker. py 2012-04-10 20:16:14 +0000 tests/test_ invoker. py 2012-04-24 22:13:23 +0000
=== modified file 'juju/hooks/
--- juju/hooks/
+++ juju/hooks/
@@ -1102,7 +1102,31 @@
@ defer.inlineCal lbacks ids(self) : a_blog( "wordpress2" ) logging( "hook") get_invoker( id="client_ id") hook("relation- ids", "db") l(result, 0) getvalue( ), "db:0\ndb:1\n\n") getvalue( ).split( ), ["db:0", "db:1"]) inlineCallbacks ids_json_ format( self): a_blog( "wordpress2" ) db_admin_ tool("admin" ) logging( "hook")
def test_relation_
- """Verify `relation-ids` command returns corresponding ids."""
+ """Verify `relation-ids` command returns white-space separated
ids."""
+ yield self.add_
+ hook_log = self.capture_
+
+ # Invoker will be in the context of the mysql/0 service unit
+ exe = yield self.ua.
+ "db:0", "add", "mysql/0", self.relation,
+ client_
+
+ # Then verify the hook lists the relation ids corresponding to
+ # the relation name `db`
+ hook = self.create_
+ result = yield exe(hook)
+ self.assertEqua
+ yield exe.ended
+ # Smart formtting outputs one id per line
+ self.assertEqual(
+ hook_log.
+ # But can be split on whitespace
+ self.assertEqual(
+ hook_log.
+
+ @defer.
+ def test_relation_
+ """Verify `relation-ids --format=json` command returns ids in
json."""
yield self.add_
yield self.add_
hook_log = self.capture_