Ejemplo n.º 1
0
def test_delete_user(db_conn):
    create_test_users(db_conn)
    user = get_user_by_id(db_conn, {'id': user_a_uuid})
    add_user_to_es(user)
    assert user
    errors = delete_user(db_conn, user_a_uuid)
    user = get_user_by_id(db_conn, {'id': user_a_uuid})
    assert not errors
    assert not user
Ejemplo n.º 2
0
def test_set_learning_context(db_conn):
    create_test_users(db_conn)
    user = get_user_by_id(db_conn, {'id': user_a_uuid})
    set_learning_context(user, unit={'entity_id': 'abcd1234'})
    context = get_learning_context(user)
    assert context
    assert context['unit']
Ejemplo n.º 3
0
def test_is_valid_token(db_conn):
    assert not is_valid_token({'id': uuid.uuid4()}, '')
    create_test_users(db_conn)
    user = get_user_by_id(db_conn, {'id': user_a_uuid})
    token = get_email_token(user)
    assert not is_valid_token(user, 'qyzjosinmal1234')
    token = get_email_token(user)
    assert is_valid_token(user, token)
Ejemplo n.º 4
0
def test_deliver_user(db_conn):
    create_test_users(db_conn)
    user = get_user_by_id(db_conn, {'id': user_a_uuid})
    user = deliver_user(user, access=None)
    assert user
    assert not user.get('email')
    assert not user.get('password')
    assert user.get('settings')
    assert not user.get('settings').get('email_frequency')
Ejemplo n.º 5
0
def test_update_user_password(db_conn):
    create_test_users(db_conn)
    prev_data = get_user_by_id(db_conn, {'id': user_a_uuid})
    assert prev_data
    data = {'password': '******'}
    user, errors = update_user_password(db_conn, prev_data, data)
    assert errors
    assert not user
    data = {'password': '******'}
    user, errors = update_user_password(db_conn, prev_data, data)
    assert not errors
    assert user
Ejemplo n.º 6
0
def test_update_user(db_conn):
    create_test_users(db_conn)
    prev_data = get_user_by_id(db_conn, {'id': user_a_uuid})
    assert prev_data
    data = {'email': 'another'}
    user, errors = update_user(db_conn, prev_data, data)
    assert errors
    assert not user
    data = {'email': '*****@*****.**'}
    user, errors = update_user(db_conn, prev_data, data)
    assert not errors
    assert user
def test_choose_unit(db_conn, session):
    """
  Expect to let a learner choose their unit.
  """

    create_route_subject_test_data(db_conn)
    current_user = get_user_by_id(db_conn, {'id': user_id})
    set_learning_context(
        user=current_user,
        subject={'entity_id': convert_uuid_to_slug(subject_a_uuid)})
    request = {
        'db_conn': db_conn,
        'cookies': {
            'session_id': session,
        },
        'params': {}
    }
    code, response = choose_unit_route(request,
                                       subject_id=subject_a_uuid,
                                       unit_id=unit_a_uuid)
    assert not response.get('errors')
    assert code == 200
    assert response['next']
Ejemplo n.º 8
0
def test_get_user_by_id(db_conn):
    create_test_users(db_conn)
    assert get_user_by_id(db_conn, {'id': user_a_uuid})
Ejemplo n.º 9
0
def test_add_user_to_es(db_conn):
    create_test_users(db_conn)
    user = get_user_by_id(db_conn, {'id': user_a_uuid})
    assert add_user_to_es(user)
Ejemplo n.º 10
0
def test_get_email_token(db_conn):
    create_test_users(db_conn)
    user = get_user_by_id(db_conn, {'id': user_a_uuid})
    token = get_email_token(user)
    assert token