本文整理汇总了Python中jobs.models.Job.key方法的典型用法代码示例。如果您正苦于以下问题:Python Job.key方法的具体用法?Python Job.key怎么用?Python Job.key使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jobs.models.Job
的用法示例。
在下文中一共展示了Job.key方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_only_admin_can_access
# 需要导入模块: from jobs.models import Job [as 别名]
# 或者: from jobs.models.Job import key [as 别名]
def test_only_admin_can_access(self):
self.client.logout()
assert self.client.login(email="[email protected]", roles=[roles.DJ])
r = self.client.post(reverse("jobs.start"), data={"job_name": "build-trafficlog-report"})
eq_(r.status_code, 403)
job = Job(job_name="build-trafficlog-report")
job.put()
r = self.client.post(reverse("jobs.work"), data={"job_key": job.key(), "params": "{}"})
eq_(r.status_code, 403)
r = self.client.post(reverse("jobs.product", args=[str(job.key())]))
eq_(r.status_code, 403)
示例2: test_only_admin_can_access
# 需要导入模块: from jobs.models import Job [as 别名]
# 或者: from jobs.models.Job import key [as 别名]
def test_only_admin_can_access(self):
self.client.logout()
assert self.client.login(email="[email protected]",
roles=[roles.DJ])
r = self.client.post(reverse('jobs.start'),
data={'job_name': 'build-trafficlog-report'})
eq_(r.status_code, 403)
job = Job(job_name='build-trafficlog-report')
job.put()
r = self.client.post(reverse('jobs.work'),
data={'job_key': job.key(),
'params': '{}'})
eq_(r.status_code, 403)
r = self.client.post(reverse('jobs.product', args=[str(job.key())]))
eq_(r.status_code, 403)
示例3: test_work
# 需要导入模块: from jobs.models import Job [as 别名]
# 或者: from jobs.models.Job import key [as 别名]
def test_work(self):
job = Job(job_name='some-job')
job.put()
response = self.client.post(reverse('jobs.work'), {
'job_key': str(job.key()),
'params': '{}'
})
self.assertEqual(response.status_code, 403)
示例4: test_get_nonexistant_job_product
# 需要导入模块: from jobs.models import Job [as 别名]
# 或者: from jobs.models.Job import key [as 别名]
def test_get_nonexistant_job_product(self):
# make a deleted job:
job = Job(job_name="counter")
job.save()
job_key = job.key()
job.delete()
response = self.client.get(reverse('jobs.product', args=(job_key,)))
self.assertEqual(response.status_code, 404)
示例5: test_job_reaper_kills_old_jobs
# 需要导入模块: from jobs.models import Job [as 别名]
# 或者: from jobs.models.Job import key [as 别名]
def test_job_reaper_kills_old_jobs(self):
# make an old job:
job = Job(job_name='counter')
job.started = datetime.datetime.now() - timedelta(days=3)
job.save()
old_job_key = job.key()
response = self.client.post(reverse('jobs.start'), {
'job_name': 'counter'
})
json_response = simplejson.loads(response.content)
self.assert_json_success(json_response)
self.assertEqual(Job.get(old_job_key), None)
示例6: test_product
# 需要导入模块: from jobs.models import Job [as 别名]
# 或者: from jobs.models.Job import key [as 别名]
def test_product(self):
job = Job(job_name='some-job')
job.put()
response = self.client.get(reverse('jobs.product',
args=[str(job.key())]))
self.assertEqual(response.status_code, 403)