Beispiel #1
0
def test_success_msg_pass_ex():
    state = prepare_state("")
    Ex(state).success_msg("NEW SUCCESS MSG")

    sct_payload = state.reporter.build_payload()
    assert sct_payload['correct'] == True
    assert sct_payload['message'] == "NEW SUCCESS MSG"
Beispiel #2
0
def test_pass(conn):
    state = State(
        student_code = "SELECT * FROM company",
        solution_code = "SELECT * FROM company",
        pre_exercise_code = "",
        student_result =  {'id': [1], 'name': ['greg']},
        solution_result = {'id': [1], 'name': ['greg']},
        student_conn = conn,
        solution_conn = None,
        reporter= Reporter())

    Ex.root_state = state

    assert Ex().check_result()
Beispiel #3
0
def test_fail(conn):
    state = State(
        student_code = "SELECT * FROM company",
        solution_code = "SELECT * FROM company",
        pre_exercise_code = "",
        student_result = {'id': [1], 'name': ['greg']},
        solution_result = {'id': [0], 'name': ['greg']},
        student_conn = conn,
        solution_conn = None,
        reporter= Reporter())

    Ex.root_state = state

    with pytest.raises(TF):
        Ex().check_result()
Beispiel #4
0
def test_pof_chain():
    state = prepare_state({'a': [1,2,3]}, {'a': [1,2,3]})
    Ex(state) >> pof()
Beispiel #5
0
def test_mc_chain_fail():
    state = prepare_state("selected_option = 2")
    with pytest.raises(TF):
        Ex(state).test_mc(1, ['good', 'bad'])
    assert state.reporter.feedback.message == 'bad'
Beispiel #6
0
def test_mc_chain_pass():
    state = prepare_state("selected_option = 1")
    Ex(state).test_mc(1, ['good', 'bad'])
    assert state.reporter.success_msg == 'good'
Beispiel #7
0
def test_check_result2_chain():
    state = prepare_state({'a': [1,2,3]}, {'a': [1,2,3]})
    Ex(state) >> check_result2()
Beispiel #8
0
def pof(state, msg='Your submission is incorrect.'):
    """High level function wrapping other SCTs, giving a pass or fail result."""
    Ex(state).check_correct(check_result_tsql(), fail(incorrect_msg=msg))
    return state