<commit_before>from flask import url_for
from flask_login import current_user

from .conftest import logged_in, assert_logged_in, DEFAULT_USERNAME


@logged_in
def test_change_password(db, client):
    new_password = DEFAULT_USERNAME + '1'
    resp = client.post(url_for('edit_own_user_profile'), follow_redirects=True,
                       data=dict(password=<PASSWORD>, new_password=<PASSWORD>, password_current=DEFAULT_USERNAME))
    assert resp.status_code == 200

    resp = client.post(url_for('login'), follow_redirects=True,
                       data=dict(username=DEFAULT_USERNAME, password=<PASSWORD>))
    assert_logged_in(resp)
    assert DEFAULT_USERNAME == current_user.name


@logged_in
def test_invalid_password_length(db, client):
    resp = client.post(url_for('edit_own_user_profile'), follow_redirects=True,
                       data=dict(password='<PASSWORD>', new_password='<PASSWORD>', password_current=DEFAULT_USERNAME))
    assert b'Field must be between 16 and 64 characters long.' in resp.data
    assert resp.status_code == 200<commit_msg>test: fix password change test by logging out before trying<commit_after>from flask import url_for
from flask_login import current_user

from .conftest import logged_in, assert_logged_in, assert_not_logged_in, DEFAULT_USERNAME


@logged_in
def test_change_password(db, client):
    new_password = <PASSWORD> + '1'
    resp = client.post(url_for('edit_own_user_profile'), follow_redirects=True,
                       data=dict(password=<PASSWORD>, new_password=<PASSWORD>, password_current=DEFAULT_USERNAME))
    assert resp.status_code == 200

    # logout and test if new password was applied
    resp = client.post(url_for('logout'), follow_redirects=True)
    assert_not_logged_in(resp)
    resp = client.post(url_for('login'), follow_redirects=True,
                       data=dict(username=DEFAULT_USERNAME, password=<PASSWORD>))
    assert_logged_in(resp)
    assert DEFAULT_USERNAME == current_user.name


@logged_in
def test_invalid_password_length(db, client):
    resp = client.post(url_for('edit_own_user_profile'), follow_redirects=True,
                       data=dict(password='<PASSWORD>', new_password='<PASSWORD>', password_current=DEFAULT_USERNAME))
    assert b'Field must be between 16 and 64 characters long.' in resp.data
    assert resp.status_code == 200
{'fraction_non_alphanumeric': 0.0955819881053526, 'fraction_numerical': 0.009345794392523364, 'mean_word_length': 4.607142857142857, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3997455', 'n_tokens_mistral': 735, 'n_tokens_neox': 702, 'n_words': 149}