예제 #1
0
def test_db_setup(db, config_path):
    """ Just check to make sure that we don't get any errors when checking for
    tables that should be created """
    from autograder import setup_app
    setup_app(config_path)

    from autograder import models as m
    assert m.db.session.query(m.User).count() == 0
예제 #2
0
def models(config_path):
    """ Setup the sqlite db and initialize the models """
    autograder.setup_app(config_path)

    # Now that setup has occurred, we can import the models
    from autograder import models as m

    # Make sure that if we've used a different db setup in another module
    # we don't keep trying to write to that database
    m.db.session.remove()

    m.drop_all()
    m.create_all()
    return m
예제 #3
0
def test_user_add(db, config_path, test_users):
    teacher_name, teacher_password, student_name, student_password = test_users

    from autograder import setup_app
    setup_app(config_path)

    from autograder import models as m
    users = m.db.session.query(m.User).all()
    assert len(users) == 2
    assert {user.username for user in users} == {teacher_name, student_name}

    if users[0].username == teacher_name:
        teacher, student = users
    else:
        student, teacher = users

    assert teacher.check_password(teacher_password)
    assert not teacher.check_password(teacher_password + 'foo')
    assert student.check_password(student_password)
    assert not student.check_password(student_password + 'bar')