Exemplo n.º 1
0
def get_content():
    """
    生成一个课程条目

    :author: lishanZheng
    :date: 2020/01/03
    """
    content_data = get_content_data()
    content = Content(**content_data, course=get_course())
    content.save()
    return content
Exemplo n.º 2
0
 def setUp(self):
     for j in range(2):
         course = get_course()
         self.course = course
         if j < 2:
             pass
         for i in range(3):
             if i < 2:
                 pass
             content_data = get_content_data()
             content = Content(**content_data, course=course)
             content.save()
             self.content = content
Exemplo n.º 3
0
    def test_add_content(self):
        """
        添加条目

        :author: lishanZheng
        :date: 2020/01/04
        """
        content_data = get_content_data()
        course = get_course()
        content_data['course'] = course.id
        res = self.client.post('/course/content', data=content_data)
        res = res.json()
        self.assertEqual(res.get('code'), result_util.SUCCESS)
        content = res.get('data')
        self.assertIsNotNone(content)
        self.assertEqual(content.get('content_name'), content_data.get('content_name'))
Exemplo n.º 4
0
    def test_modify_course(self):
        """
        修改课程

        :author: lishanZheng
        :date: 2020/01/05
        """
        course_data = get_course_data()
        course_old = get_course()
        result_modify = self.client.put('/course/course/' + str(course_old.id),
                                        data=course_data,
                                        content_type='application/json')
        res = result_modify.json()
        modified_course = res.get('data')
        self.assertEqual(res.get('code'), SUCCESS)
        self.assertEqual(modified_course.get('name'), course_data.get('name'))
        self.assertEqual(modified_course.get('introduction'),
                         course_data.get('introduction'))
        self.assertEqual(modified_course.get('location'),
                         course_data.get('location'))
Exemplo n.º 5
0
 def setUp(self):
     course = None
     clazz = get_clazz()
     times = 5
     self.times = times
     self.state_open = 1
     self.state_close = 0
     self.old_clazz_id = clazz.id
     # 3个状态为1 2个为0
     for i in range(times):
         course = get_course()
         course.state = self.state_close
         course.clazz_id = clazz.id
         course.save()
         if i < 2:
             course.state = self.state_open
             course.save()
     # 最后一个clazz_id与上面不同
     clazz = get_clazz()
     course.clazz = clazz
     course.save()
     self.new_clazz_id = clazz.id