示例#1
0
def test_max_submissions_invalid():
    course = Course(id=5)
    a = Assignment(deadline=None, is_lti=False, course=course)
    with pytest.raises(exceptions.APIException):
        a.max_submissions = 0

    with pytest.raises(exceptions.APIException):
        a.max_submissions = -1
示例#2
0
def test_update_amount_in_cool_off_period_invalid():
    course = Course(id=5)
    a = Assignment(deadline=None, is_lti=False, course=course)
    with pytest.raises(exceptions.APIException):
        a.amount_in_cool_off_period = 0

    with pytest.raises(exceptions.APIException):
        a.amount_in_cool_off_period = -1

    a.amount_in_cool_off_period = 1
示例#3
0
def test_update_cgignore_invalid():
    course = Course(id=5)
    a = Assignment(deadline=None, is_lti=False, course=course)
    with pytest.raises(exceptions.APIException):
        a.update_cgignore('invalid', 'err')

    with pytest.raises(exceptions.APIException):
        a.update_cgignore('IgnoreFilterManager', ['not a string'])

    with pytest.raises(exceptions.APIException):
        a.update_cgignore('SubmissionValidator', 'not a dict')
示例#4
0
def test_deadline_expired_property(monkeypatch):
    course = Course(id=5)
    a = Assignment(deadline=None, is_lti=False, course=course)
    assert not a.deadline_expired

    before = datetime.utcnow()
    monkeypatch.setattr(helpers, 'get_request_start_time', datetime.utcnow)

    a.deadline = before
    assert a.deadline_expired

    a.deadline = datetime.utcnow() + timedelta(hours=1)
    assert not a.deadline_expired
示例#5
0
 def make(id=None):
     course = Course(id=5)
     a = Assignment(course=course, is_lti=False)
     a.id = id
     return a