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


Python SectionFactory.create方法代码示例

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


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

示例1: test_crns

# 需要导入模块: from courses.tests.factories import SectionFactory [as 别名]
# 或者: from courses.tests.factories.SectionFactory import create [as 别名]
    def test_crns(self):
        course = CourseFactory.create()
        section1 = SectionFactory.create(crn=123, course=course)
        section2 = SectionFactory.create(crn=124, course=course)
        SectionPeriodFactory.create(section=section1)
        SectionPeriodFactory.create(section=section2)

        self.assertEqual([123, 124], list(course.crns))
开发者ID:Lucky1313,项目名称:YACS,代码行数:10,代码来源:models.py

示例2: test_conflicts_with_section_with_conflicting_periods

# 需要导入模块: from courses.tests.factories import SectionFactory [as 别名]
# 或者: from courses.tests.factories.SectionFactory import create [as 别名]
    def test_conflicts_with_section_with_conflicting_periods(self):
        def period():
            m = Mock()
            m.conflicts_with = Mock(return_value=True)
            return m
        section1, section2 = SectionFactory.create(), SectionFactory.create()
        section1.get_periods = Mock(return_value=[period()])
        section2.get_periods = Mock(return_value=[period()])

        self.assertTrue(section1.conflicts_with(section2))
开发者ID:Lucky1313,项目名称:YACS,代码行数:12,代码来源:models.py

示例3: test_full_crns

# 需要导入模块: from courses.tests.factories import SectionFactory [as 别名]
# 或者: from courses.tests.factories.SectionFactory import create [as 别名]
    def test_full_crns(self):
        course = CourseFactory.create()
        section1 = SectionFactory.create(
            crn=123, course=course, seats_total=1, seats_taken=0)
        section2 = SectionFactory.create(
            crn=124, course=course, seats_total=1, seats_taken=5)
        SectionPeriodFactory.create(section=section1)
        SectionPeriodFactory.create(section=section2)

        self.assertEqual([124], list(course.full_crns))
开发者ID:Lucky1313,项目名称:YACS,代码行数:12,代码来源:models.py

示例4: test_kinds

# 需要导入模块: from courses.tests.factories import SectionFactory [as 别名]
# 或者: from courses.tests.factories.SectionFactory import create [as 别名]
    def test_kinds(self):
        course = CourseFactory.create()
        section1 = SectionFactory.create(crn=123, course=course)
        section2 = SectionFactory.create(crn=124, course=course, seats_total=1)
        SectionPeriodFactory.create(section=section1, kind='foo')
        SectionPeriodFactory.create(section=section1, kind='foobar')
        SectionPeriodFactory.create(section=section1, kind='fizzbuzz')
        SectionPeriodFactory.create(section=section2, kind='fizz')

        self.assertEqual(set(['foo', 'foobar', 'fizzbuzz', 'fizz']), set(course.kinds))
开发者ID:Lucky1313,项目名称:YACS,代码行数:12,代码来源:models.py

示例5: setUp

# 需要导入模块: from courses.tests.factories import SectionFactory [as 别名]
# 或者: from courses.tests.factories.SectionFactory import create [as 别名]
    def setUp(self):
        semester = SemesterFactory.create(year=2011, month=1)
        course = CourseFactory.create(pk=2)
        OfferedForFactory.create(semester=semester, course=course)

        section = SectionFactory.create(number=1, course=course, semester=semester)
        sa_section = SectionFactory.create(number=models.Section.STUDY_ABROAD, course=course, semester=semester)
        crn_section = SectionFactory.create(crn=13337, course=course, semester=semester)

        cs_dept = DepartmentFactory.create(code='CSCI')
        SemesterDepartmentFactory.create(semester=semester, department=cs_dept)

        ecse_dept = DepartmentFactory.create(code='ECSE')
        SemesterDepartmentFactory.create(semester=semester, department=ecse_dept)

        self.semester, self.course, self.cs_dept, self.ecse_dept = semester, course, cs_dept, ecse_dept
开发者ID:Radzell,项目名称:YACS,代码行数:18,代码来源:smokes.py

示例6: test_days_of_week

# 需要导入模块: from courses.tests.factories import SectionFactory [as 别名]
# 或者: from courses.tests.factories.SectionFactory import create [as 别名]
    def test_days_of_week(self):
        section = SectionFactory.create()
        period1 = PeriodFactory.create(days_of_week_flag=models.Period.TUESDAY)
        period2 = PeriodFactory.create(days_of_week_flag=models.Period.MONDAY)
        SectionPeriodFactory.create(period=period1, section=section)
        SectionPeriodFactory.create(period=period2, section=section)

        expected = ['Monday', 'Tuesday']
        self.assertEqual(expected, section.days_of_week)
开发者ID:Lucky1313,项目名称:YACS,代码行数:11,代码来源:models.py

示例7: setUp

# 需要导入模块: from courses.tests.factories import SectionFactory [as 别名]
# 或者: from courses.tests.factories.SectionFactory import create [as 别名]
    def setUp(self):
        self.sem = SemesterFactory.create(year=2011, month=1)
        self.dept = DepartmentFactory.create(code='CSCI')
        SemesterDepartmentFactory.create(department=self.dept, semester=self.sem)

        self.course = CourseFactory.create(number=2222, department=self.dept)
        OfferedForFactory.create(course=self.course, semester=self.sem)

        self.section = SectionFactory.create(course=self.course, semester=self.sem)
        SectionPeriodFactory.create(section=self.section)
开发者ID:TimeFinders,项目名称:YAExS,代码行数:12,代码来源:querysets.py

示例8: test_saving_and_loading

# 需要导入模块: from courses.tests.factories import SectionFactory [as 别名]
# 或者: from courses.tests.factories.SectionFactory import create [as 别名]
    def test_saving_and_loading(self):
        course1 = CourseFactory.create()
        course2 = CourseFactory.create()
        section1 = SectionFactory.create(course=course1)
        section2 = SectionFactory.create(course=course1)
        section3 = SectionFactory.create(course=course2)

        json = self.json_post('v4:saved-selections', data={
            'section_ids': ','.join([
                str(section1.id),
                str(section2.id),
                str(section3.id),
            ]),
            'blocked_times': ','.join(['Wednesday_12:0:0', 'Thursday_14:0:0'])
        }, status_code=200)

        selection = SavedSelection.objects.all()[0]

        expected_json = {
            u"version": 4,
            u"success": True,
            u"result": {
                u'id': selection.id,
                u'selection': {
                    unicode(course1.id): [
                        section1.id,
                        section2.id,
                    ],
                    unicode(course2.id): [
                        section3.id
                    ]
                },
                u'blocked_times': [
                    u'Thursday_14:0:0',
                    u'Wednesday_12:0:0',
                ]
            }
        }

        self.assertEqual(json, expected_json)
        json = self.json_post('v4:saved-selection', id=selection.id, status_code=200)
        self.assertEqual(json, expected_json)
开发者ID:Radzell,项目名称:YACS,代码行数:44,代码来源:tests.py

示例9: test_search_instructor

# 需要导入模块: from courses.tests.factories import SectionFactory [as 别名]
# 或者: from courses.tests.factories.SectionFactory import create [as 别名]
 def test_search_instructor(self):
     c1, c2 = CourseFactory.create_batch(2)
     c3 = CourseFactory.create()
     sec = SectionFactory.create(course=c3)
     sp = SectionPeriodFactory.create(section=sec, instructor='Moorthy')
     json = self.json_get('v4:courses', get='?search=moor', status_code=200)
     self.maxDiff = None
     self.assertEqual(json, {
         u"version": 4,
         u"success": True,
         u"result": [
             self.to_dict(c3),
         ]
     })
开发者ID:Radzell,项目名称:YACS,代码行数:16,代码来源:tests.py

示例10: test_to_json

# 需要导入模块: from courses.tests.factories import SectionFactory [as 别名]
# 或者: from courses.tests.factories.SectionFactory import create [as 别名]
 def test_to_json(self):
     section = SectionFactory.create(
         number=1, crn=2, seats_taken=3, seats_total=4
     )
     expected = {
         'number': 1,
         'crn': 2,
         'periods': [],
         'seats_taken': 3,
         'seats_total': 4,
         'seats_left': 1,
         'notes': [],
     }
     result = section.toJSON()
     self.assertEqual(expected, result)
开发者ID:Lucky1313,项目名称:YACS,代码行数:17,代码来源:models.py

示例11: test_is_study_abroad

# 需要导入模块: from courses.tests.factories import SectionFactory [as 别名]
# 或者: from courses.tests.factories.SectionFactory import create [as 别名]
 def test_is_study_abroad(self):
     section = SectionFactory.create(number=models.Section.STUDY_ABROAD)
     self.assertTrue(section.is_study_abroad)
开发者ID:jeffh,项目名称:YACS,代码行数:5,代码来源:test_models.py

示例12: test_is_not_full

# 需要导入模块: from courses.tests.factories import SectionFactory [as 别名]
# 或者: from courses.tests.factories.SectionFactory import create [as 别名]
 def test_is_not_full(self):
     section = SectionFactory.create()
     self.assertFalse(section.is_full)
开发者ID:jeffh,项目名称:YACS,代码行数:5,代码来源:test_models.py

示例13: test_no_conflicts_using_cache

# 需要导入模块: from courses.tests.factories import SectionFactory [as 别名]
# 或者: from courses.tests.factories.SectionFactory import create [as 别名]
 def test_no_conflicts_using_cache(self):
     section1, section2 = SectionFactory.create(), SectionFactory.create()
     section1.conflicts = set()
     self.assertFalse(section1.conflicts_with(section2))
开发者ID:Lucky1313,项目名称:YACS,代码行数:6,代码来源:models.py

示例14: test_conflicts_with_using_cache

# 需要导入模块: from courses.tests.factories import SectionFactory [as 别名]
# 或者: from courses.tests.factories.SectionFactory import create [as 别名]
 def test_conflicts_with_using_cache(self):
     section1, section2 = SectionFactory.create(), SectionFactory.create()
     section1.conflicts = set([section2.id])
     self.assertTrue(section1.conflicts_with(section2))
开发者ID:Lucky1313,项目名称:YACS,代码行数:6,代码来源:models.py

示例15: test_is_full

# 需要导入模块: from courses.tests.factories import SectionFactory [as 别名]
# 或者: from courses.tests.factories.SectionFactory import create [as 别名]
 def test_is_full(self):
     section = SectionFactory.create(seats_taken=2, seats_total=2)
     self.assertTrue(section.is_full)
开发者ID:jeffh,项目名称:YACS,代码行数:5,代码来源:test_models.py


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