def METHOD_NAME(app, release):
    user = db_utils.create_user(username='user1', password='password1')
    app.set_cookie(*db_utils.create_session(user).split('=', 1))
    resp = app.get('/control/username')
    assert 'username_release' not in resp.forms
    assert 'disabled' not in resp.html.find(id='new_username').attrs
    assert resp.html.find(id='avatar')['alt'] == 'user1'
    assert app.get('/~user1').html.select_one('link[rel=canonical]')['href'] == 'https://www.weasyl.com/~user1'
    assert app.get('/~user1snewusername', status=404).html.find(id='error_content').p.string == "This user doesn't seem to be in our database."
    form = resp.forms['username_change']
    form['new_username'] = "user1's new username"
    assert form.submit('do').html.find(id='error_content').p.string == 'Your username has been changed.'
    resp = app.get('/control/username')
    assert 'username_release' in resp.forms
    assert 'disabled' in resp.html.find(id='new_username').attrs
    assert resp.html.find(id='avatar')['alt'] == "user1's new username"
    assert app.get('/~user1').html.select_one('link[rel=canonical]')['href'] == 'https://www.weasyl.com/~user1snewusername'
    assert app.get('/~user1snewusername').html.select_one('link[rel=canonical]')['href'] == 'https://www.weasyl.com/~user1snewusername'
    if release:
        form = resp.forms['username_release']
        assert form.submit('do').html.find(id='error_content').p.string == 'Your old username has been released.'
        resp = app.get('/control/username')
        assert resp.html.find(id='avatar')['alt'] == "user1's new username"
        assert app.get('/~user1', status=404).html.find(id='error_content').p.string == "This user doesn't seem to be in our database."
        assert app.get('/~user1snewusername').html.select_one('link[rel=canonical]')['href'] == 'https://www.weasyl.com/~user1snewusername'
    form = resp.forms['username_change']
    form['new_username'] = 'user2'
    assert form.submit('do', status=422).html.find(id='error_content').p.string == "You can't change your username within 30 days of a previous change."
    d.engine.execute("UPDATE username_history SET replaced_at = replaced_at - INTERVAL '30 days'")
    assert form.submit('do').html.find(id='error_content').p.string == 'Your username has been changed.'
    resp = app.get('/control/username')
    assert resp.html.find(id='avatar')['alt'] == 'user2'
    assert app.get('/~user1', status=404).html.find(id='error_content').p.string == "This user doesn't seem to be in our database."
    assert app.get('/~user1snewusername').html.select_one('link[rel=canonical]')['href'] == 'https://www.weasyl.com/~user2'
    assert app.get('/~user2').html.select_one('link[rel=canonical]')['href'] == 'https://www.weasyl.com/~user2'
    form = resp.forms['username_change']
    form['new_username'] = 'U S E R 2'
    d.engine.execute("UPDATE username_history SET replaced_at = replaced_at - INTERVAL '30 days'")
    assert form.submit('do').html.find(id='error_content').p.string == 'Your username has been changed.'
    resp = app.get('/control/username')
    assert 'disabled' not in resp.html.find(id='new_username').attrs
    assert resp.html.find(id='avatar')['alt'] == 'U S E R 2'
    assert app.get('/~user1snewusername').html.select_one('link[rel=canonical]')['href'] == 'https://www.weasyl.com/~user2'
    assert app.get('/~user2').html.select_one('link[rel=canonical]')['href'] == 'https://www.weasyl.com/~user2'
    form = resp.forms['username_change']
    form['new_username'] = 'user3'
    assert form.submit('do').html.find(id='error_content').p.string == 'Your username has been changed.'
    resp = app.get('/control/username')
    assert resp.html.find(id='avatar')['alt'] == 'user3'
    assert app.get('/~user1snewusername', status=404).html.find(id='error_content').p.string == "This user doesn't seem to be in our database."
    assert app.get('/~user2').html.select_one('link[rel=canonical]')['href'] == 'https://www.weasyl.com/~user3'
    assert app.get('/~user3').html.select_one('link[rel=canonical]')['href'] == 'https://www.weasyl.com/~user3'