def patched_sync_service(mock_queue_client, host=host, cpu_id=0): s = SyncService(process_identifier='{}:{}'.format(host, cpu_id), cpu_id=cpu_id) s.queue_client = mock_queue_client s.start_sync = mock.Mock( side_effect=lambda aid: s.syncing_accounts.add(aid)) return s
def patched_sync_service(db, mock_queue_client, host=host, process_number=0): s = SyncService(process_identifier='{}:{}'.format(host, process_number), process_number=process_number) s.queue_client = mock_queue_client def start_sync(aid): acc = db.session.query(Account).get(aid) acc.sync_host = s.process_identifier acc.sync_started() s.syncing_accounts.add(aid) db.session.commit() s.start_sync = mock.Mock(side_effect=start_sync) return s
def patched_sync_service(db, mock_queue_client, host=host, cpu_id=0): s = SyncService(process_identifier='{}:{}'.format(host, cpu_id), cpu_id=cpu_id) s.queue_client = mock_queue_client def start_sync(aid): acc = db.session.query(Account).get(aid) acc.sync_host = s.process_identifier acc.sync_started() s.syncing_accounts.add(aid) db.session.commit() s.start_sync = mock.Mock(side_effect=start_sync) return s