Exemple #1
0
def test_as_tod_string():
    d = ct.DayTime(18, 30)
    assert '18:30' == d.as_tod_string()

    d = ct.DayTime(3, 5)
    assert '03:05' == d.as_tod_string()

    w = ct.WeekTime(3, 18, 30)
    assert '18:30' == w.as_tod_string()
Exemple #2
0
def test_section_int():
    d1 = ct.DayTime(9, 0)
    d2 = ct.DayTime(9, 50)
    s = courses.Section('LEC', 'John Doe', 'MWF', d1, d2)

    assert 'LEC' == s.kind
    assert 'John Doe' == s.instructor
    assert ['M', 'W', 'F'] == s.days
    assert d1 == s.start
    assert d2 == s.end
Exemple #3
0
def test_order():
    d1 = ct.DayTime(3, 0)
    d2 = ct.DayTime(3, 15)
    assert d1 < d2

    d1 = ct.DayTime(1, 15)
    d2 = ct.DayTime(2, 15)
    assert d1 < d2

    w1 = ct.WeekTime(1, 3, 15)
    w2 = ct.WeekTime(2, 3, 15)
    assert w1 < w2
Exemple #4
0
def test_course_init():
    d1 = ct.DayTime(9, 0)
    d2 = ct.DayTime(9, 50)
    s = courses.Section('LEC', 'John Doe', 'MWF', d1, d2)
    c1 = courses.Course('Mathematics', 'MATH', 4130, 'Analysis', ['LEC'], [s])
    c2 = courses.Course('Mathematics', 'MATH', '4130', 'Analysis', ['LEC'], [s])

    assert c1 == c2
    assert (c1.as_json() == {
        'department' : 'Mathematics',
        'dept_short' : 'MATH',
        'number' : '4130',
        'title' : 'Analysis',
        'required' : ['LEC'],
        'sections' : [s.as_json()]
    })
Exemple #5
0
def test_section_as_json():
    d1 = ct.DayTime(9, 0)
    d2 = ct.DayTime(9, 50)
    s = courses.Section('LEC', 'John Doe', 'MWF', d1, d2)

    start_row = 1 + ((d1.hour - 8) * 12) + (d1.minute / 5)
    end_row = 1 + ((d2.hour - 8) * 12) + (d2.minute / 5)

    assert (s.as_json() == {
        'kind' : 'LEC',
        'instructor' : 'John Doe',
        'ref' : 'MWF 09:00 - 09:50',
        'day_idxs' : [1, 3, 5],
        'start_row' : start_row,
        'end_row' : end_row
    })
Exemple #6
0
def test_section_repr():
    d1 = ct.DayTime(9, 0)
    d2 = ct.DayTime(9, 50)
    s = courses.Section('LEC', 'John Doe', 'MWF', d1, d2)
    assert s == eval('courses.' + s.__repr__())
Exemple #7
0
def test_parse_time():
    d = ct.DayTime(7, 55)
    assert d == ct.DayTime.parse_time_string('07:55AM')

    d = ct.DayTime(17, 15)
    assert d == ct.DayTime.parse_time_string('05:15PM')
Exemple #8
0
def test_daytime_init():
    d = ct.DayTime(18, 30)
    assert 18 == d.hour
    assert 30 == d.minute
Exemple #9
0
def test_repr():
    d = ct.DayTime(18, 29)
    assert d == eval('ct.' + d.__repr__())

    w = ct.WeekTime(2, 18, 29)
    assert w == eval('ct.' + w.__repr__())