示例#1
0
    def test_valid_add_course_form(self):
        name = "C++"
        number = "03210100"
        credits = "3"

        data = {
            "name": name,
            "number": number,
            "credits": credits,
        }

        form = AddCourse(data=data)
        self.assertTrue(form.is_valid())
示例#2
0
    def test_invalid_add_course_form_negative_credits(self):
        name = "test"
        number = "023301"
        credits = "-3"

        data = {
            "name": name,
            "number": number,
            "credits": credits,
        }

        form = AddCourse(data=data)
        self.assertFalse(form.is_valid())
示例#3
0
    def test_invalid_add_course_form_empty_name(self):
        name = ""
        number = "1234"
        credits = "3"

        data = {
            "name": name,
            "number": number,
            "credits": credits,
        }

        form = AddCourse(data=data)
        self.assertFalse(form.is_valid())
示例#4
0
    def test_invalid_add_course_form_invalid_number(self):
        name = "test"
        number = "asv"
        credits = "2"

        data = {
            "name": name,
            "number": number,
            "credits": credits,
        }

        form = AddCourse(data=data)
        self.assertFalse(form.is_valid())
示例#5
0
    def test_invalid_add_course_form_empty_fields(self):
        name = ""
        number = ""
        prerequisite = ""
        credits = ""
        chosen_by = ""

        data = {
            "name": name,
            "number": number,
            "prerequisite": prerequisite,
            "credits": credits,
            "chosen_by": chosen_by,
        }

        form = AddCourse(data=data)
        self.assertFalse(form.is_valid())