当前位置: 首页>>代码示例>>Python>>正文


Python Entry.full_clean方法代码示例

本文整理汇总了Python中models.Entry.full_clean方法的典型用法代码示例。如果您正苦于以下问题:Python Entry.full_clean方法的具体用法?Python Entry.full_clean怎么用?Python Entry.full_clean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Entry的用法示例。


在下文中一共展示了Entry.full_clean方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import full_clean [as 别名]
    def setUp(self):
        if 'TEST_PROVIDER' in os.environ:
            self.good_provider = os.environ['TEST_PROVIDER']
        else:
            # This is the default server thread started by django test,
            # but it only works for this app.
            self.good_provider = 'http://localhost:8081/'  # default
        self.bad_provider = 'http://127.0.0.1:65535/'

        self.teacher_data = [('[email protected]', 'Jeff T', [['MG4', '1st period math', TeacherClass()]]),
                             ('[email protected]', 'Jeff J', [['MG4', '5th period math', TeacherClass()]])]
        self.email1 = self.teacher_data[0][0]
        self.name1 = self.teacher_data[0][1]

        self.u1_password = 'F00LI5H'
        self.u1 = User.objects.create_user(username='user1', email='[email protected]',
                                           password=self.u1_password)
        user = authenticate(username=self.u1.username, password=self.u1_password)
        assert user

        self.teachers = []
        for teacher_email, teacher_name, teacher_classes in self.teacher_data:
            t = Teacher(email=teacher_email, name=teacher_name, user=self.u1)
            t.full_clean()
            t.save()
            self.teachers.append(t)

            for i in range(len(teacher_classes)):
                course_id, class_name, _ = teacher_classes[i]
                c = TeacherClass(name=class_name,
                                 course_id=course_id,
                                 teacher=t,
                                 repo_provider=self.good_provider)
                c.full_clean()
                c.save()
                teacher_classes[i][2] = c

        # create a calendar entry for the 2nd teacher
        teacher_2 = self.teacher_data[1]
        teacher_2_class = teacher_2[2][0][2]
        e1 = Entry(teacher=self.teachers[1], teacher_class=teacher_2_class, date=datetime.date.today(),
                   objective='MG4-FACTMULT')
        e1.full_clean()
        e1.save()

        self.good_course = 'MG4'
        self.bad_course = 'xxx' + self.good_course + 'xxx'
开发者ID:trawick,项目名称:edurepo,代码行数:49,代码来源:tests.py

示例2: test_duplicate_class_objective

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import full_clean [as 别名]
    def test_duplicate_class_objective(self):
        tc = TeacherClass(name='1st period math (TDCO)',
                          course_id=self.good_course, teacher=self.teachers[0],
                          repo_provider=self.good_provider)
        tc.full_clean()
        tc.save()

        same_class = tc
        same_day = datetime.date.today()
        same_objective = 'MG4-FACTMULT'
        e1 = Entry(teacher=self.teachers[0], teacher_class=same_class, date=same_day,
                   objective=same_objective)
        e1.full_clean()
        e1.save()
        e2 = Entry(teacher=self.teachers[0], teacher_class=same_class, date=same_day,
                   objective=same_objective)
        self.assertRaises(ValidationError, lambda: e2.full_clean())
开发者ID:trawick,项目名称:edurepo,代码行数:19,代码来源:tests.py


注:本文中的models.Entry.full_clean方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。