示例#1
0
	def test_course_form_rejects_invalid_data(self):
		form = CourseForm(self.bad_data)
		self.assertFalse(form.is_valid())


    # def test_course_form_rejects_invalid_data(self):
    #     form = CourseForm(self.bad_data)
    #     self.assertFalse(form.is_valid()) 
示例#2
0
文件: views.py 项目: RayFerr000/PLTL
def course_list(request):
	course_info = Course.objects.all()
	if request.method == 'POST':
		form = CourseForm(request.POST)
		if form.is_valid():
			new_course = form.save(commit=False)
			new_course = form.save()
	else:
		form = CourseForm()

	return render_to_response('courses.html',{'courses': course_info, 'form': form},context_instance=RequestContext(request))
示例#3
0
	def test_course_form_accepts_valid_data(self):
		form = CourseForm(self.data)
		self.assertTrue(form.is_valid())
示例#4
0
 def test_introduction_field(self):
     form = CourseForm()
     label = form.fields['introduction'].label
     max_length = form.fields['introduction'].max_length
     self.assertTrue(label == None or label == '简介')
     self.assertEqual(max_length, 150)
示例#5
0
 def test_charge_field(self):
     form = CourseForm()
     label = form.fields['charge'].label
     self.assertTrue(label == None or label == '课程收费')
示例#6
0
 def test_subject_field(self):
     form = CourseForm()
     label = form.fields['subject'].label
     self.assertTrue(label == None or label == '科目')
示例#7
0
 def test_grade_course_field(self):
     form = CourseForm()
     label = form.fields['grade_course'].label
     self.assertTrue(label == None or label == '学生年级')
示例#8
0
 def test_nick_name_field(self):
     form = CourseForm()
     label = form.fields['nick_name'].label
     max_length = form.fields['nick_name'].max_length
     self.assertTrue(label == None or label == '课程名称')
     self.assertEqual(max_length, 50)