[Telepathy-commits] [telepathy-gabble/master] jingletest.py: refactor create_content_node helper as a standalone method

Senko Rasic senko.rasic at collabora.co.uk
Tue Jan 20 03:06:17 PST 2009


---
 tests/twisted/jingle/jingletest.py |   40 +++++++++++++++++------------------
 1 files changed, 19 insertions(+), 21 deletions(-)

diff --git a/tests/twisted/jingle/jingletest.py b/tests/twisted/jingle/jingletest.py
index c3f17de..e6ad3ef 100644
--- a/tests/twisted/jingle/jingletest.py
+++ b/tests/twisted/jingle/jingletest.py
@@ -186,28 +186,26 @@ class JingleTest:
 
         self.stream.send(iq.toXml())
 
+    def create_content_node(self, name, type, codecs):
+        content = domish.Element((None, 'content'))
+        content['creator'] = 'initiator'
+        content['name'] = name
+        content['senders'] = 'both'
 
-    def outgoing_call_reply(self, session_id, accept, with_video=False):
-
-        def create_content_node(name, type, codecs):
-            content = domish.Element((None, 'content'))
-            content['creator'] = 'initiator'
-            content['name'] = name
-            content['senders'] = 'both'
-
-            desc = domish.Element(("http://jabber.org/protocol/jingle/description/" + type, 'description'))
-            for codec, id, rate in codecs:
-                p = domish.Element((None, 'payload-type'))
-                p['name'] = codec
-                p['id'] = str(id)
-                p['rate'] = str(rate)
-                desc.addChild(p)
-            content.addChild(desc)
+        desc = domish.Element(("http://jabber.org/protocol/jingle/description/" + type, 'description'))
+        for codec, id, rate in codecs:
+            p = domish.Element((None, 'payload-type'))
+            p['name'] = codec
+            p['id'] = str(id)
+            p['rate'] = str(rate)
+            desc.addChild(p)
+        content.addChild(desc)
 
-            xport = domish.Element(("http://www.google.com/transport/p2p", 'transport'))
-            content.addChild(xport)
-            return content
+        xport = domish.Element(("http://www.google.com/transport/p2p", 'transport'))
+        content.addChild(xport)
+        return content
 
+    def outgoing_call_reply(self, session_id, accept, with_video=False):
         self.session_id = session_id
         self.direction = 'outgoing'
 
@@ -217,11 +215,11 @@ class JingleTest:
 
         iq, jingle = self._jingle_stanza('session-accept')
 
-        jingle.addChild(create_content_node('stream1', 'audio',
+        jingle.addChild(self.create_content_node('stream1', 'audio',
             self.audio_codecs))
 
         if with_video:
-            jingle.addChild(create_content_node('stream2', 'video',
+            jingle.addChild(self.create_content_node('stream2', 'video',
                 self.video_codecs))
 
         self.stream.send(iq.toXml())
-- 
1.5.6.5




More information about the Telepathy-commits mailing list