def _test_post_job_destruction(self, username):
'''
POST /{jobs}/{job-id}/destruction with DESTRUCTION={std:iso8601}
(application/x-www-form-urlencoded) sets the destruction instant for
{job-id} and redirects to /{jobs}/{job-id} as 303.
'''
destruction_time = '2016-01-01T00:00:00'
for job in self.jobs:
url = reverse(self.url_names['destruction'], kwargs={'pk': job.pk})
response = self.client.post(url, urlencode({'DESTRUCTION': destruction_time}), content_type='application/x-www-form-urlencoded')
if username == 'user':
redirect_url = 'http://testserver' + reverse(self.url_names['detail'], kwargs={'pk': job.pk})
self.assertRedirects(response, redirect_url, status_code=303)
self.assertEqual(
self.jobs.get(pk=job.pk).destruction_time,
iso8601.parse_date('2016-01-01T00:00:00')
)
else:
self.assertEqual(response.status_code, 404)
评论列表
文章目录