Пример #1
0
  def get(self, author):
    self.response.headers['Access-Control-Allow-Origin'] = '*'

    author_object = Author.get_by_id(author.lower())
    if author_object is None or author_object.status != Status.ready:
      self.response.set_status(404)
      return

    metadata = json.loads(author_object.metadata)

    result = {
        'type': metadata['type'],
        'login': metadata['login'],
        'name': metadata['name'],
        'company': metadata['company'],
        'blog': metadata['blog'],
        'location': metadata['location'],
        'email': metadata['email'],
        'bio': metadata['bio'],
        'avatar_url': metadata['avatar_url'],
        'followers': metadata['followers'],
        'following': metadata['following'],
        'public_gists': metadata['public_gists'],
        'public_repos': metadata['public_repos'],
    }

    self.response.headers['Content-Type'] = 'application/json'
    self.response.write(json.dumps(result))
Пример #2
0
 def init_author(self, name, insert):
   name = name.lower()
   if insert:
     self.author = Author.get_or_insert(name)
   else:
     self.author = Author.get_by_id(name)
   if self.author.status == Status.suppressed:
     raise RequestAborted('author is suppressed')
   self.author_dirty = False
Пример #3
0
 def init_author(self, name, insert):
     name = name.lower()
     if insert:
         self.author = Author.get_or_insert(name)
     else:
         self.author = Author.get_by_id(name)
     if self.author.status == Status.suppressed:
         raise RequestAborted('author is suppressed')
     self.author_dirty = False
Пример #4
0
  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)
Пример #5
0
  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)
Пример #6
0
  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)
Пример #7
0
  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)
Пример #8
0
 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')
Пример #9
0
 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')