예제 #1
0
파일: lab.py 프로젝트: Roasbeef/GauchoSwap
def get_lab_by_id(lab_id):
    wants_json = request_wants_json()
    try:
        lab = api.get_course_by_id("lab", lab_id, json=wants_json)
    except api.DbNotFoundError:
        abort(404)

    return jsonify({"lab": lab}) if wants_json else render_template("couse_page.html", course=lab)
예제 #2
0
def get_lecture_by_id(lecture_id):
    wants_json = request_wants_json()

    try:
        lecture = api.get_course_by_id('lecture', lecture_id, json=wants_json)
    except api.DbNotFoundError:
        abort(404)

    return jsonify({'lecture': lecture}) if wants_json else render_template('course_page.html', course=lecture)
예제 #3
0
def get_section_by_id(section_id):
    wants_json = request_wants_json()

    try:
        section = api.get_course_by_id('section', section_id, json=wants_json)
    except api.DbNotFoundError:
        abort(404)

    return jsonify({'section': section}) if wants_json else render_template('course_page.html', course=section)
예제 #4
0
    def test_get_section_by_id(self):
        # empty db should have nothing
        sections = api.get_courses('section')
        self.assertFalse(list(sections))

        # Create 5 sections where every attribute is the same as the ID
        self.create_test_sections()

        # Try to get all Sections based on ID
        # Check will be made by comparing Section name to Section ID, which in this test are the same
        for i in range(5):
            section = api.get_course_by_id('section', i + 1)
            self.assertEqual(section.name, str(i + 1))