示例#1
0
def test_text_content():
    test_app = app.test_client()
    content = '<h1>Great headline</h1>'
    # Create a content file
    with open('manufactorum/content/test_text_content.html', 'w') as f:
        f.write(content)

    # Create path file
    with open('manufactorum/templates/_test_text_content.html', 'w') as f:
        f.write("{{ text_content('test_text_content.html')|safe }}")

    data = test_app.get('/test_text_content').data.decode('utf8')
    assert content in data
    assert 'tinymce.init' not in data

    os.remove('manufactorum/templates/_test_text_content.html')
    os.remove('manufactorum/content/test_text_content.html')
示例#2
0
from manufactorum import app, cache
from tests.unittest_utils import temp_file

app.config.update(TESTING=True)
app.config.update(WTF_CSRF_ENABLED=False)
app.config.update(DEBUG=True)
client = app.test_client()


def test_routes():
    response = client.get('/')
    assert response.status_code == 200

    response = client.get('/test_routes')
    assert response.status_code == 404

    content = ('This is my unit test. '
               'There are many like it but this one is mine')
    with temp_file('manufactorum/templates/_test_routes.html', content):
        response = client.get('/test_routes')
        assert response.data.decode('utf8') == content

    cache.clear()

    response = client.get('/test_routes')
    assert response.status_code == 404


def test_reserved_routes():
    response = client.get('/login')
    data = response.data.decode('utf8')