<commit_before>import bottle
import webtest
import app

import pytest

"""
Scenarios:
    User visits / and is redirected to /index
    When /<pagename> has no content, a 404 page is displayed with a link to /<pagename>/edit
    /<pagename>/edit has a form for editing the content and changing the name
    User creates a new page
    User modifies a page
    User browses pages
"""

@pytest.fixture
def db(scope='function'):
    app.dbfunctions.init_db(':memory:')
    yield
    app.dbfunctions.init_db()

@pytest.fixture
def testapp():
    return webtest.TestApp(bottle.default_app())

def test_index(testapp):
    response = testapp.get('/')
    assert response.status == '200 OK'

def test_edit(db, testapp):
    article = 'This is a test article'
    testapp.post('/edit', params={'subject':'Test Subject', 'article':article})
    response = testapp.get('/test')
    assert article in response.body.decode('UTF-8')

def test_edit_squeeze(db, monkeypatch):
    class Stub:
        forms = {'subject':"Test", 'article':"This is a test."}
    monkeypatch.setattr(app, 'request', Stub())
    with pytest.raises(bottle.HTTPResponse):
        app.edit()
<commit_msg>Rename test_edit_squeeze to test_edit_post<commit_after>import bottle
import webtest
import app

import pytest

"""
Scenarios:
    User visits / and is redirected to /index
    When /<pagename> has no content, a 404 page is displayed with a link to /<pagename>/edit
    /<pagename>/edit has a form for editing the content and changing the name
    User creates a new page
    User modifies a page
    User browses pages
"""

@pytest.fixture
def db(scope='function'):
    app.dbfunctions.init_db(':memory:')
    yield
    app.dbfunctions.init_db()

@pytest.fixture
def testapp():
    return webtest.TestApp(bottle.default_app())

def test_index(testapp):
    response = testapp.get('/')
    assert response.status == '200 OK'

def test_edit(db, testapp):
    article = 'This is a test article'
    testapp.post('/edit', params={'subject':'Test Subject', 'article':article})
    response = testapp.get('/test')
    assert article in response.body.decode('UTF-8')

def test_edit_post(db, monkeypatch):
    class Stub:
        forms = {'subject':"Test", 'article':"This is a test."}
    monkeypatch.setattr(app, 'request', Stub())
    with pytest.raises(bottle.HTTPResponse):
        app.edit()

{'fraction_non_alphanumeric': 0.12478777589134125, 'fraction_numerical': 0.005942275042444821, 'mean_word_length': 3.7329317269076303, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '4085860', 'n_tokens_mistral': 767, 'n_tokens_neox': 758, 'n_words': 223}