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)
def test_conflicts_with_uses_period_conflict(self): period1 = PeriodFactory.build() period1.conflicts_with = Mock(return_value=False) period2 = PeriodFactory.build() sp1 = SectionPeriodFactory.build(period=period1) sp2 = SectionPeriodFactory.build(period=period2) self.assertFalse(sp1.conflicts_with(sp2)) period1.conflicts_with.assert_called_with(period2)
def test_does_not_conflicts_with(self): p = PeriodFactory.build( start=datetime.time(hour=8), end=datetime.time(hour=9), days_of_week_flag=1 ) self.assertFalse(self.period.conflicts_with(p))
def test_conflicts_with(self): p = PeriodFactory.create( start=datetime.time(hour=7), end=datetime.time(hour=9), days_of_week_flag=1 ) self.assertTrue(self.period.conflicts_with(p))
def setUp(self): super(SearchTest, self).setUp() course = CourseFactory.create(department=self.cs_dept, number=4230, name='Intro to Computing') OfferedForFactory.create(course=course, semester=self.semester) course2 = CourseFactory.create(department=self.cs_dept, number=4231, name='Skynet 101') OfferedForFactory.create(course=course2, semester=self.semester) # another department course3 = CourseFactory.create(department=self.ecse_dept, number=4230, name='Imaginary Power') OfferedForFactory.create(course=course3, semester=self.semester) section = SectionFactory.create(course=course, semester=self.semester) period = PeriodFactory.create(start=datetime.time(hour=12), end=datetime.time(hour=13), days_of_week_flag=1) SectionPeriodFactory.create(section=section, period=period, instructor='Moorthy', semester=self.semester) self.course1, self.course2, self.course3 = course, course2, course3
def create_periods(*ranges): periods = [] for start, end, dow in ranges: periods.append(PeriodFactory.create( start=time(*start), end=time(*end), days_of_week_flag=dow, )) return periods
def create_periods(*ranges): periods = [] for start, end, dow in ranges: periods.append( PeriodFactory.create( start=time(*start), end=time(*end), days_of_week_flag=dow, )) return periods
def test_to_json(self): period = PeriodFactory.create() period.toJSON = Mock(return_value={'lol': 1}) sp = SectionPeriodFactory.create( instructor='foo', location='bar', kind='fizz', period=period, ) expected = { 'instructor': 'foo', 'location': 'bar', 'kind': 'fizz', 'lol': 1, 'id': sp.id, } self.assertEqual(expected, sp.toJSON())
def setUp(self): self.start = datetime.time(hour=7) self.end = datetime.time(hour=7, minute=50) self.period = PeriodFactory.create(start=self.start, end=self.end, days_of_week_flag=1)
def test_display_period_of_4_to_5(self): period = PeriodFactory.build(start=time(hour=4), end=time(hour=5)) self.assertEqual(display_period(period), '4:00-5:00 am')
def test_display_period_with_minutes(self): period = PeriodFactory.build(start=time(hour=4), end=time(hour=4, minute=50)) self.assertEqual(display_period(period), '4:00-4:50 am')
def setUp(self): self.period = PeriodFactory.create(start=None, end=None, days_of_week_flag=1)
def test_display_period_in_the_afternoon(self): period = PeriodFactory.build(start=time(hour=14), end=time(hour=14, minute=50)) self.assertEqual(display_period(period), '2:00-2:50 pm')
def test_display_period_from_morning_to_afternoon(self): period = PeriodFactory.build(start=time(hour=10), end=time(hour=14, minute=50)) self.assertEqual(display_period(period), '10:00 am-2:50 am')
def test_conflicts_with(self): p = PeriodFactory.build(start=datetime.time(hour=7), end=datetime.time(hour=9), days_of_week_flag=1) self.assertTrue(self.period.conflicts_with(p))
def test_does_not_conflicts_with(self): p = PeriodFactory.create(start=datetime.time(hour=8), end=datetime.time(hour=9), days_of_week_flag=1) self.assertFalse(self.period.conflicts_with(p))