test_views.py 文件源码

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

项目:Odin 作者: HackSoftware 项目源码 文件源码
def test_post_creates_instance_when_data_is_valid(self):
        add_teacher(course=self.course, teacher=self.teacher)
        self.course.start_date = timezone.now().date() + timezone.timedelta(days=1)
        self.course.end_date = timezone.now().date() + timezone.timedelta(days=2)
        self.course.save()
        current_app_info_count = ApplicationInfo.objects.count()
        self.start_date = timezone.now().date() + timezone.timedelta(days=1)
        self.end_date = timezone.now().date() + timezone.timedelta(days=2)

        data = {
            'start_date': self.start_date,
            'end_date': self.end_date,
        }

        with self.login(email=self.user.email, password=self.test_password):
            response = self.post(self.url, data=data)

            self.assertRedirects(response,
                                 expected_url=reverse('dashboard:education:user-course-detail',
                                                      kwargs={'course_id': self.course.id}))
            self.assertEqual(current_app_info_count + 1, ApplicationInfo.objects.count())
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号