Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar/presence/test_presence.txt
blob: d0736a9643daf30bc6e5085c2938ca1e327cd7d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
This is a test of presence.

To test this service we will start up a mock dbus library:

    >>> from sugar.testing import mockdbus
    >>> import dbus
    >>> pres_service = mockdbus.MockService(
    ...     'org.laptop.Presence', '/org/laptop/Presence', name='pres')
    >>> pres_service.install()
    >>> pres_interface = dbus.Interface(pres_service, 'org.laptop.Presence')

Then we import the library (second, to make sure it connects to our
mocked system, though the lazy instantiation in get_instance() should
handle it):

    >>> from sugar.presence import PresenceService
    >>> ps = PresenceService.get_instance()
    >>> pres_interface.make_response('getServices', [])
    >>> ps.get_services()
    Called pres.org.laptop.Presence:getServices()
    []
    >>> pres_interface.make_response('getBuddies', [])
    >>> ps.get_buddies()
    Called pres.org.laptop.Presence:getBuddies()
    []