summaryrefslogtreecommitdiff
path: root/src/dbus/server/pim/testpim.py
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2013-05-07 16:39:50 +0200
committerPatrick Ohly <patrick.ohly@intel.com>2013-05-16 11:24:48 +0200
commitb6b75de59ba284b0497e450d2bbe76523d1ee523 (patch)
treef4e30e372d6eb766b9d0c36c82adf4eb230c6243 /src/dbus/server/pim/testpim.py
parentd3eee8a0390558795ace8be503b44d76be385b13 (diff)
PIM: new return value for SyncPeer(), new SyncProgress signal (FDO #63417)
The SyncPeer() result is derived from the sync statistics. To have them available, the "sync done" signal must include the SyncReport. Start and end of a sync could already be detected; "modified" signals while a sync runs depends on a new signal inside the SyncContext when switching from one cycle to the next and at the end of the last one.
Diffstat (limited to 'src/dbus/server/pim/testpim.py')
-rwxr-xr-xsrc/dbus/server/pim/testpim.py93
1 files changed, 84 insertions, 9 deletions
diff --git a/src/dbus/server/pim/testpim.py b/src/dbus/server/pim/testpim.py
index 6f384b75..9e5efc58 100755
--- a/src/dbus/server/pim/testpim.py
+++ b/src/dbus/server/pim/testpim.py
@@ -649,6 +649,24 @@ END:VCARD(\r|\n)*''',
expected = sources.copy()
peers = {}
+ syncProgress = []
+ signal = bus.add_signal_receiver(lambda uid, event, data: (logging.printf('received SyncProgress: %s, %s, %s', uid, event, data), syncProgress.append((uid, event, data)), logging.printf('progress %s' % syncProgress)),
+ 'SyncProgress',
+ 'org._01.pim.contacts.Manager',
+ None, #'org._01.pim.contacts',
+ '/org/01/pim/contacts',
+ byte_arrays=True,
+ utf8_strings=True)
+ def checkSync(expected, result):
+ self.assertEqual(expected, result)
+ while not (uid, 'done', {}) in syncProgress:
+ self.loopIteration('added signal')
+ self.assertEqual([(uid, 'started', {}),
+ (uid, 'modified', expected),
+ (uid, 'done', {})],
+ syncProgress)
+
+
# Must be the Bluetooth MAC address (like A0:4E:04:1E:AD:30)
# of a phone which is paired, currently connected, and
# supports both PBAP and SyncML. SyncML is needed for putting
@@ -707,7 +725,9 @@ END:VCARD(\r|\n)*''',
# Remember current list of files and modification time stamp.
files = listsyncevo()
- # Remove all data locally.
+ # Remove all data locally. There may or may not have been data
+ # locally, because the database of the peer might have existed
+ # from previous tests.
self.manager.SyncPeer(uid,
timeout=self.timeout)
# TODO: check that syncPhone() really used PBAP - but how?
@@ -817,8 +837,14 @@ END:VCARD
output.write(john)
output.close()
self.syncPhone(phone, uid)
- self.manager.SyncPeer(uid,
- timeout=self.timeout)
+ syncProgress = []
+ result = self.manager.SyncPeer(uid,
+ timeout=self.timeout)
+ checkSync({'modified': True,
+ 'added': 1,
+ 'updated': 0,
+ 'removed': 0},
+ result)
# Also exclude modified database files.
self.assertEqual(files, listsyncevo(exclude=exclude))
@@ -834,16 +860,28 @@ END:VCARD
peers[uid],
timeout=self.timeout)
files = listsyncevo(exclude=exclude)
- self.manager.SyncPeer(uid,
- timeout=self.timeout)
+ syncProgress = []
+ result = self.manager.SyncPeer(uid,
+ timeout=self.timeout)
+ checkSync({'modified': False,
+ 'added': 0,
+ 'updated': 0,
+ 'removed': 0},
+ result)
exclude.append(logdir + '(/$)')
self.assertEqual(files, listsyncevo(exclude=exclude))
self.assertEqual(2, len(os.listdir(logdir)))
# At most one!
- self.manager.SyncPeer(uid,
- timeout=self.timeout)
+ syncProgress = []
+ result = self.manager.SyncPeer(uid,
+ timeout=self.timeout)
+ checkSync({'modified': False,
+ 'added': 0,
+ 'updated': 0,
+ 'removed': 0},
+ result)
exclude.append(logdir + '(/$)')
self.assertEqual(files, listsyncevo(exclude=exclude))
self.assertEqual(2, len(os.listdir(logdir)))
@@ -854,12 +892,49 @@ END:VCARD
peers[uid],
timeout=self.timeout)
files = listsyncevo(exclude=exclude)
- self.manager.SyncPeer(uid,
- timeout=self.timeout)
+ syncProgress = []
+ result = self.manager.SyncPeer(uid,
+ timeout=self.timeout)
+ checkSync({'modified': False,
+ 'added': 0,
+ 'updated': 0,
+ 'removed': 0},
+ result)
exclude.append(logdir + '(/$)')
self.assertEqual(files, listsyncevo(exclude=exclude))
self.assertEqual(4, len(os.listdir(logdir)))
+ # Update contact.
+ john = '''BEGIN:VCARD
+VERSION:3.0
+FN:John Doe
+N:Doe;John
+END:VCARD'''
+ output = open(item, "w")
+ output.write(john)
+ output.close()
+ self.syncPhone(phone, uid)
+ syncProgress = []
+ result = self.manager.SyncPeer(uid,
+ timeout=self.timeout)
+ checkSync({'modified': True,
+ 'added': 0,
+ 'updated': 1,
+ 'removed': 0},
+ result)
+
+ # Remove contact.
+ os.unlink(item)
+ self.syncPhone(phone, uid)
+ syncProgress = []
+ result = self.manager.SyncPeer(uid,
+ timeout=self.timeout)
+ checkSync({'modified': True,
+ 'added': 0,
+ 'updated': 0,
+ 'removed': 1},
+ result)
+
# Test invalid maxsession values.
with self.assertRaisesRegexp(dbus.DBusException,
"negative 'maxsessions' not allowed: -1"):