def handle_get(self): queue = taskqueue.Queue('update') if queue.fetch_statistics().tasks > 0: self.response.write('update already in progress') return query = Library.query() cursor = None more = True task_count = 0 while more: keys, cursor, more = query.fetch_page(50, keys_only=True, start_cursor=cursor) for key in keys: task_count = task_count + 1 task_url = util.update_library_task(key.id()) util.new_task(task_url, target='manage', queue_name='update') logging.info('triggered %d library updates', task_count) query = Author.query() cursor = None more = True task_count = 0 while more: keys, cursor, more = query.fetch_page(50, keys_only=True, start_cursor=cursor) for key in keys: task_count = task_count + 1 task_url = util.update_author_task(key.id()) util.new_task(task_url, target='manage', queue_name='update') logging.info('triggered %d author updates', task_count)
def handle_get(self): queue = taskqueue.Queue('update') if queue.fetch_statistics().tasks > 0: self.response.write('update already in progress') return query = Library.query() cursor = None more = True task_count = 0 while more: keys, cursor, more = query.fetch_page(50, keys_only=True, start_cursor=cursor) for key in keys: task_count = task_count + 1 task_url = util.update_library_task(key.id()) util.new_task(task_url, target='manage', queue_name='update') logging.info('triggered %d library updates', task_count) query = Author.query() cursor = None more = True task_count = 0 while more: keys, cursor, more = query.fetch_page(50, keys_only=True, start_cursor=cursor) for key in keys: task_count = task_count + 1 task_url = util.update_author_task(key.id()) util.new_task(task_url, target='manage', queue_name='update') logging.info('triggered %d author updates', task_count)
def test_delete_missing_author(self): author = Author(id='test') author.put() self.respond_to_github('https://api.github.com/users/test', {'status': 404}) response = self.app.get(util.update_author_task('TEST'), headers={'X-AppEngine-QueueName': 'default'}) self.assertEqual(response.status_int, 200) author = Author.get_by_id('test') self.assertIsNone(author)
def test_delete_missing_author(self): author = Author(id='test') author.put() self.respond_to_github('https://api.github.com/users/test', {'status': 404}) response = self.app.get(util.update_author_task('TEST'), headers={'X-AppEngine-QueueName': 'default'}) self.assertEqual(response.status_int, 200) author = Author.get_by_id('test') self.assertIsNone(author)
def test_update_all(self): library_key = Library(id='owner/repo').put() author_key = Author(id='owner').put() response = self.app.get('/manage/update-all', headers={'X-AppEngine-QueueName': 'default'}) self.assertEqual(response.status_int, 200) tasks = self.tasks.get_filtered_tasks() self.assertEqual([ util.update_library_task(library_key.id()), util.update_author_task(author_key.id()), ], [task.url for task in tasks])
def test_update_all(self): library_key = Library(id='owner/repo').put() author_key = Author(id='owner').put() response = self.app.get('/manage/update-all', headers={'X-AppEngine-QueueName': 'default'}) self.assertEqual(response.status_int, 200) tasks = self.tasks.get_filtered_tasks() self.assertEqual([ util.update_library_task(library_key.id()), util.update_author_task(author_key.id()), ], [task.url for task in tasks])