Example #1
0
def test_edit_sessions(client, auth):
    auth.login_teacher()
    assert client.get('sessions/1/edit').status_code == 200
    with client:
        client.post('sessions/1/edit', data = {'session_time': 'MTWRF', 'student_email': ['*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**']})

        with db.get_db() as con:
            with con.cursor() as cur:
                cur.execute("SELECT * FROM sessions WHERE id = 1")
                session = cur.fetchone()
                assert session['meets'] == 'MTWRF'

                cur.execute("SELECT * FROM user_sessions WHERE session_id = 1")
                students = cur.fetchall()
                assert len(students) == 4
Example #2
0
def test_edit_course_teacher(client, course, auth, app):
    auth.login_teacher()
    course.create('test', 'testing')
    assert client.get('courses/1/edit').status_code == 200
    client.post('courses/1/edit',
                data={
                    'course_number': 'test2',
                    'course_title': 'testing2'
                })
    with app.app_context():
        with db.get_db() as con:
            with con.cursor() as cur:
                cur.execute("SELECT * FROM courses WHERE id = 1")
                course = cur.fetchone()
    assert course['course_number'] == 'test2'
Example #3
0
def test_create_course_teacher(client, auth, app, course):
    #Testing GET request
    assert client.get('/courses/create').status_code == 302
    auth.login_teacher()
    assert client.get('/courses/create').status_code == 200
    response = client.get('/courses/create')
    assert b'Course Number' in response.data
    assert b'Course Title' in response.data
    #Testing POST request
    course.create('test', 'testing')
    with app.app_context():
        with db.get_db() as con:
            with con.cursor() as cur:
                check = cur.execute(
                    "SELECT * FROM courses WHERE course_number = 'test'")
                check = cur.fetchone()
        assert check is not None
Example #4
0
def test_create_session_teacher(client, auth, app, course):
    #Testing GET request
    assert client.get('/sessions/1/create').status_code == 302
    auth.login_teacher()
    assert client.get('/sessions/1/create').status_code == 200
    response = client.get('/sessions/1/create')
    assert b'Session Time' in response.data
    assert b'Student Email' in response.data
    #Testing POST request
    course.create('test', 'testing')
    client.post('/sessions/1/create', data={'session_time': 'test time', 'student_list': ['*****@*****.**', '*****@*****.**', '*****@*****.**']})
    with app.app_context():
        with db.get_db() as con:
            with con.cursor() as cur:
                cur.execute("SELECT * FROM sessions WHERE course_id = 1")
                check = cur.fetchone()
        assert check['id'] is 1
        assert check['letter'] is 'A'
Example #5
0
def test_grade_assignment_teacher(client, auth, app):
    auth.login_teacher()
    assert client.get('assignments/grade/1/2').status_code == 200
    client.post('assignments/grade/1/2',
                data={
                    'points_scored': 8,
                    'feedback': 'Great Work!'
                })

    with app.app_context():
        with db.get_db() as con:
            with con.cursor() as cur:
                cur.execute(
                    "SELECT * FROM submissions WHERE assignment_id = 1 AND student_id = 2"
                )
                submission = cur.fetchone()

    assert submission['points_scored'] == 8
    assert submission['feedback'] == 'Great Work!'
Example #6
0
def test_edit_assignment_teacher(client, auth, app):
    auth.login_teacher()
    assert client.get('assignments/edit/1').status_code == 200
    client.post('assignments/edit/1',
                data={
                    'assignment_name': 'test2',
                    'assignment_description': 'testing2',
                    'type': 'default',
                    'total_points': '30'
                })

    with app.app_context():
        with db.get_db() as con:
            with con.cursor() as cur:
                cur.execute("SELECT * FROM assignments WHERE id = 1")
                assignment = cur.fetchone()

    assert assignment['assignment_name'] == 'test2'
    assert assignment['assignment_description'] == 'testing2'
    assert assignment['type'] == 'default'
    assert assignment['total_points'] == 30
Example #7
0
def test_create_assignment_teacher(client, auth, app):
    #Testing GET request
    assert client.get('/assignments/1/create').status_code == 302
    auth.login_teacher()
    assert client.get('/assignments/1/create').status_code == 200
    response = client.get('/assignments/1/create')
    assert b'Assignment Name' in response.data
    assert b'Assignment Description' in response.data
    #Testing POST request
    client.post('/assignments/1/create',
                data={
                    'assignment_name': 'test',
                    'assignment_description': 'testing',
                    'type': 'default',
                    'total_points': '30'
                })
    with app.app_context():
        with db.get_db() as con:
            with con.cursor() as cur:
                check = cur.execute(
                    "SELECT * FROM assignments WHERE assignment_name = 'test'")
                check = cur.fetchone()
        assert check is not None
Example #8
0
def test_show_assignment_teacher(client, auth):
    auth.login_teacher()
    assert client.get('assignments/1').status_code == 200
Example #9
0
def test_grade_fake_assignment(client, auth):
    auth.login_teacher()
    assert client.get('assignments/grade/9').status_code == 404
Example #10
0
def test_show_course_teacher(client, auth):
    auth.login_teacher()
    assert client.get('courses/1/course').status_code == 200
    response = client.get('courses/1/course')
    assert b'Your Assignments' in response.data
Example #11
0
def test_list_courses_teacher(client, auth):
    assert client.get('/courses/list').status_code == 302
    auth.login_teacher()
    assert client.get('/courses/list').status_code == 200
    response = client.get('/courses/list')
    assert b'Your Courses' in response.data