mixins.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:django-daiquiri 作者: aipescience 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号