dbus/python/tests test-client.py,NONE,1.1 test-server.py,NONE,1.1

Seth Nickell seth at pdx.freedesktop.org
Sat May 29 22:30:11 PDT 2004


Update of /cvs/dbus/dbus/python/tests
In directory pdx:/tmp/cvs-serv2439/python/tests

Added Files:
	test-client.py test-server.py 
Log Message:
2004-05-30  Seth Nickell  <seth at gnome.org>

	* python/dbus_bindings.pyx.in:

	Add support for ObjectPath type.

	* python/dbus.py:

	Refactor message handling code to a common function.
	
	* python/tests/test-client.py:
	* python/tests/test-server.py:

	Add tests that check to make sure values of all types
	can be echoed from a service w/o mangling.


--- NEW FILE: test-client.py ---
import dbus
import dbus_bindings


def TestEcho(value, should_be_equal = True):
    global remote_object
    echoed = remote_object.Echo(value)
    if type(echoed) != type(value):
        raise Exception ("Sending %s, expected echo of type %s, but got %s" % (value, type(value), type(echoed)))

    if echoed.__class__ != value.__class__:
        raise Exception ("Sending %s, expected echo to be of class %s, but got %s" % (value, value.__class__, echoed.__class__))

    if should_be_equal:
        if echoed != value:
            raise Exception("Sending %s, expected echo to be the same, but was %s" % (value, echoed))

session_bus = dbus.SessionBus()

remote_service = session_bus.get_service("org.designfu.Test")
remote_object = remote_service.get_object("/TestObject", "org.designfu.Test")

TestEcho(chr(120))
TestEcho(10)
TestEcho(39.5)
TestEcho("HelloWorld")
TestEcho(dbus_bindings.ObjectPath("/test/path"))


--- NEW FILE: test-server.py ---
import dbus
import gtk

class TestObject(dbus.Object):
    def __init__(self, service):
        method_list = [ self.Echo ]
        dbus.Object.__init__(self, "/TestObject", method_list, service)

    def Echo(self, variable):
        return variable
            
session_bus = dbus.SessionBus()

local_service = dbus.Service("org.designfu.Test", bus=session_bus)
local_object = TestObject(local_service)

gtk.main()




More information about the dbus-commit mailing list