示例#1
0
文件: jobs.py 项目: weinvest/catapult
def _GetJobs(options):
    user = api_auth.Email()
    if user:
        query = job_module.Job.query(job_module.Job.user == user)
    else:
        query = job_module.Job.query()

    query = query.order(-job_module.Job.created)
    job_future = query.fetch_async(limit=_MAX_JOBS_TO_FETCH)
    count_future = query.count_async(limit=_MAX_JOBS_TO_COUNT)

    result = {
        'jobs': [],
        'count': count_future.get_result(),
        'max_count': _MAX_JOBS_TO_COUNT
    }

    jobs = job_future.get_result()
    for job in jobs:
        result['jobs'].append(job.AsDict(options))

    return result
示例#2
0
文件: new.py 项目: genovia/catapult
def _ValidateUser(arguments):
    return arguments.get('user') or api_auth.Email()
示例#3
0
文件: new.py 项目: weinvest/catapult
def _ValidateUser(user):
    return user or api_auth.Email()
示例#4
0
 def testEmail_NoUser(self):
   self.mock_get_current_user.side_effect = oauth.InvalidOAuthParametersError
   self.assertIsNone(api_auth.Email())
示例#5
0
 def testEmail(self):
   self.mock_get_current_user.return_value = _UNAUTHORIZED_USER
   self.assertEqual(api_auth.Email(), '*****@*****.**')