def test_ensure_when_missing(self): response = self.app.get(util.ensure_author_task('author'), headers={'X-AppEngine-QueueName': 'default'}) self.assertEqual(response.status_int, 200) tasks = self.tasks.get_filtered_tasks() self.assertEqual([ util.ingest_author_task('author'), ], [task.url for task in tasks])
def test_ingest_author(self): metadata = '{HI}' self.respond_to_github('https://api.github.com/users/name', metadata) response = self.app.get(util.ingest_author_task('NAME'), headers={'X-AppEngine-QueueName': 'default'}) self.assertEqual(response.status_int, 200) author = Author.get_by_id('name') self.assertIsNone(author.error) self.assertEqual(author.status, 'ready') self.assertEqual(author.metadata, metadata)
def handle_get(self, name): author = Author.get_by_id(name.lower()) if author is None: task_url = util.ingest_author_task(name) util.new_task(task_url, target='manage')