コード例 #1
0
def test_course2():
    """Test for XML loading errors"""
    errorstore = ErrorStore()
    course = load_course("testcourses/testcourse2", "coursefile.xml",
                         errorstore)
    handle_course2_errors(errorstore)
    assert_caught_all_errors(errorstore)
コード例 #2
0
def test_course3():
    """Test for XML error in course.xml"""
    errorstore = ErrorStore()
    course = load_course("testcourses/testcourse3", "course.xml", errorstore)
    assert_error(errorstore, InvalidXML, 'course.xml',
                 'attributes construct error, line 1, column 61')
    assert_caught_all_errors(errorstore)
コード例 #3
0
def test_course1():
    """Make sure that things load properly when everything is ok"""
    errorstore = ErrorStore()
    course = load_course("testcourses/testcourse1", "course.xml", errorstore)
    assert errorstore.errors == []

    assert course.attributes == {
        'url_name': 'mycourseurl',
        'org': 'myorg',
        'course': 'mycourse'
    }

    [chapter] = course.children
    assert chapter.attributes == {
        'url_name': 'chapter',
        'display_name': 'chapter name'
    }

    [sequential] = chapter.children
    assert sequential.attributes == {
        'url_name': 'sequential',
        'display_name': 'display name'
    }

    [vertical] = sequential.children
    assert vertical.attributes == {
        'url_name': 'vertical',
        'display_name': 'vertical name'
    }

    [html] = vertical.children
    assert html.attributes == {'url_name': 'html', 'display_name': 'html name'}
    assert '<p>Test course</p>' in etree.tostring(html.content,
                                                  pretty_print=True).decode()
コード例 #4
0
def test_no_course():
    errorstore = ErrorStore()
    course = load_course("testcourses", "nocourse.xml", errorstore)
    handle_nocourse_errors(errorstore)
    assert_caught_all_errors(errorstore)