dbus/test/python test-client.py,1.3,1.4

John Palmieri johnp at freedesktop.org
Wed Oct 5 13:43:49 PDT 2005


Update of /cvs/dbus/dbus/test/python
In directory gabe:/tmp/cvs-serv16663/test/python

Modified Files:
	test-client.py 
Log Message:
* glib/dbus-gvalue.c (marshal_variant): call _dbus_gvalue_marshal
  instead of marshal basic so we can handle recursive types in a variant

* test/glib/test-dbus-glib.c: Add test for marshaling recurive types
  in variants

* test/glib/test-service-glib.c, test-service-glib.xml
  (my_object_echo_variant [EchoVariant],
  my_object_process_variant_of_array_of_ints123
  [ProcessVariantOfArrayOfInts123]):
  Add two test methods

* python/introspect_parser.py: New module for parsing introspect
  data.

* python/dbus_bindings.pyx:
  (various places): when throwing errors fix to use errormsg instead
  of message local variable because Pyrex can get confused with other
  message variables (initial patch by Robert McQueen
  <robert.mcqueen at collabora.co.uk>)
  (MessageIter::parse_signature_block): new method for getting the next
  block in a signiture.
  (MessageIter::append_strict): new method for appending values strictly
  using the passed in signature instead of guessing at the type
  (MessageItter:: append_dict, append_struct, append_array): use
  signatures to marshal children if the signature is available

* python/exceptions.py (IntrospectionParserException): new exception

* python/proxies.py (ProxyMethod::__call__): Marshal args with
  introspected signatures if available, else we fall back to the
  old way of doing things.
  (ProxyObject::_introspect_reply_handler ): parse introspection data

* python/service.py (ObjectType::_reflect_on_method): Properly
  terminate <method> if there are no args in the reflection data

* test/python/test-client.py: add tests for talking with the GLib
  test server.  This gives us better coverage for introspection since
  python to python will always generate arguments as variants.  It also
  allows us to test the robustness of the GLib bindings and interlanguage
  communications.



Index: test-client.py
===================================================================
RCS file: /cvs/dbus/dbus/test/python/test-client.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- test-client.py	1 Sep 2005 01:22:06 -0000	1.3
+++ test-client.py	5 Oct 2005 20:43:46 -0000	1.4
@@ -20,13 +20,7 @@
 if not dbus_bindings.__file__.startswith(pydir):
     raise Exception("DBus modules are not being picked up from the package")
 
-class TestDBusBindings(unittest.TestCase):
-    def setUp(self):
-        self.bus = dbus.SessionBus()
-        self.remote_object = self.bus.get_object("org.freedesktop.DBus.TestSuitePythonService", "/org/freedesktop/DBus/TestSuitePythonObject")
-        self.iface = dbus.Interface(self.remote_object, "org.freedesktop.DBus.TestSuiteInterface")
-
-        self.test_types_vals = [1, 12323231, 3.14159265, 99999999.99,
+test_types_vals = [1, 12323231, 3.14159265, 99999999.99,
                  "dude", "123", "What is all the fuss about?", "gob at gob.com",
                  [1,2,3], ["how", "are", "you"], [1.23,2.3], [1], ["Hello"],
                  (1,2,3), (1,), (1,"2",3), ("2", "what"), ("you", 1.2),
@@ -35,6 +29,13 @@
                  ([1,2,3],"c", 1.2, ["a","b","c"], {"a": (1,"v"), "b": (2,"d")})
                  ]
 
+
+class TestDBusBindings(unittest.TestCase):
+    def setUp(self):
+        self.bus = dbus.SessionBus()
+        self.remote_object = self.bus.get_object("org.freedesktop.DBus.TestSuitePythonService", "/org/freedesktop/DBus/TestSuitePythonObject")
+        self.iface = dbus.Interface(self.remote_object, "org.freedesktop.DBus.TestSuiteInterface")
+
     def testInterfaceKeyword(self):
         #test dbus_interface parameter
         print self.remote_object.Echo("dbus_interface on Proxy test Passed", dbus_interface = "org.freedesktop.DBus.TestSuiteInterface")
@@ -52,7 +53,7 @@
         #test sending python types and getting them back
         print "\n********* Testing Python Types ***********"
                  
-        for send_val in self.test_types_vals:
+        for send_val in test_types_vals:
             print "Testing %s"% str(send_val)
             recv_val = self.iface.Echo(send_val)
             self.assertEquals(send_val, recv_val)
@@ -82,8 +83,8 @@
 
                 self.test_controler.assert_(val, False)
         
-        last_type = self.test_types_vals[-1]
-        for send_val in self.test_types_vals:
+        last_type = test_types_vals[-1]
+        for send_val in test_types_vals:
             print "Testing %s"% str(send_val)
             check = async_check(self, send_val, last_type == send_val) 
             recv_val = self.iface.Echo(send_val, 
@@ -91,7 +92,45 @@
                                        error_handler = check.error_handler)
             
         main_loop.run()
-   
+
+class TestDBusPythonToGLibBindings(unittest.TestCase):
+    def setUp(self):
+        self.bus = dbus.SessionBus()
+        self.remote_object = self.bus.get_object("org.freedesktop.DBus.TestSuiteGLibService", "/org/freedesktop/DBus/Tests/MyTestObject")
+        self.iface = dbus.Interface(self.remote_object, "org.freedesktop.DBus.Tests.MyObject")
+			    
+    def testIntrospection(self):
+	#test introspection
+        print "\n********* Introspection Test ************"
+        print self.remote_object.Introspect(dbus_interface="org.freedesktop.DBus.Introspectable")
+        print "Introspection test passed"
+        self.assert_(True)
+
+    def testCalls(self):
+        print "\n********* Call Test ************"
+        result =  self.iface.ManyArgs(1000, 'Hello GLib', 2)
+        print result
+        self.assert_(result == [2002.0, 'HELLO GLIB'])
+	
+        arg0 = {"Dude": 1, "john": "palmieri", "python": 2.4}
+        result = self.iface.ManyStringify(arg0)
+        print result
+       
+        print "Call test passed"
+        self.assert_(True)
+
+    #this crashes glib so disable it for now
+    #until glib is fixed
+    """
+    def testPythonTypes(self):
+        print "\n********* Testing Python Types ***********"
+                 
+        for send_val in test_types_vals:
+            print "Testing %s"% str(send_val)
+            recv_val = self.iface.EchoVariant(send_val)
+            self.assertEquals(send_val, recv_val)
+    """
+
 if __name__ == '__main__':
     gobject.threads_init()
     dbus.glib.init_threads()



More information about the dbus-commit mailing list