def test_signal_before_query(self): request = { 'all_count': 1, 'out': [ { 'uid': 1 } ] } signals = [] def signals_cb(s): signals.append(s) def timeout_cb(): gtk.main_quit() glib.timeout_add(500, timeout_cb) s = DatastoreRichSource() s.connect('objects-updated', signals_cb) ds.call('Created', { 'uid': 1 }) ds.call('Created', { 'uid': 2 }) ds.call('Updated', { 'uid': 2 }) ds.call('Created', { 'uid': 3 }) ds.call('Deleted', { 'uid': 3 }) s.on_query(request) gtk.main() self.assertEqual([s], signals) self.assertEqual(request['out'][0], s.get_row(0)) self.assertEqual(1, s.get_count())
def call_cb(): ds.call('Created', { 'uid': 2, '_tags_': '[[["B"], "__tag_B__"]]' }) ds.call('Created', { 'uid': 3, '_tags_': '[[["B"], "__tag_B__"]]', 'timestamp': 1 }) ds.call('Updated', { 'uid': 3, '_tags_': '[[["C"], "__tag_C__"]]', 'timestamp': 2 }) ds.call('Created', { 'uid': 4, '_tags_': '[[["C"], "__tag_C__"]]' }) ds.call('Deleted', { 'uid': 4 }) def timeout_cb(): gtk.main_quit() glib.timeout_add(500, timeout_cb) return False
def call_cb(): ds.call('Updated', { 'uid': 1, 'activity_id': 1, 'timestamp': 1 }) return False
def delete_cb(): ds.call('Deleted', { 'uid': 4 }) return False
def update_cb(): ds.call('Updated', { 'uid': 3, 'title': '1', 'timestamp': 5 }) return False
def add_cb(): ds.call('Created', { 'uid': 3, 'title': '4', 'timestamp': 3 }) ds.call('Created', { 'uid': 4, 'title': '3', 'timestamp': 4 }) return False
def call_cb(): self.assertEqual(request['out'][1], s.get_row(0)) self.assertEqual(1, s.get_count()) ds.call('Deleted', { 'uid': 2 }) return False
def call_cb(): self.assertEqual(request['out'][1], s.get_row(0)) self.assertEqual(1, s.get_count()) ds.call('Updated', { 'uid': 1, 'activity_id': 1, 'timestamp': 3, '_tags_': '[[["C"], "__tag_C__"]]' }) return False
def call_cb(): ds.call('Created', { 'uid': 2, 'activity_id': 1, 'timestamp': 2, '_tags_': '[[["B"], "__tag_B__"]]' }) return False
def signal_cb(s): if len(semaphore): semaphore.pop() ds.call('Created', { 'uid': 2, 'activity_id': 1, 'timestamp': 2, '_tags_': '[[["A"], "__tag_A__"]]' }) ds.call('Updated', { 'uid': 3, 'activity_id': 1, 'timestamp': 3, '_tags_': '[[["A"], "__tag_A__"]]' })
def signal_cb(s): ds.call('Created', { 'uid': 2, 'bundle_id': 1, 'activity_version': 1, '_tags_': '[[["B"], "__tag_B__"]]' }) ds.call('Updated', { 'uid': 3, 'bundle_id': 1, 'activity_version': 1, '_tags_': '[[["C"], "__tag_C__"]]' }) gtk.main_quit()