Esempio n. 1
0
def test_path_related_funciton(client):

    helpers.create_page_in_database("TEST_TITLE", "BLAHBLAH")
    assert helpers.get_links() != []

    assert helpers.check_duplicate("TEST TITLE")
    assert not helpers.check_duplicate("doesnt exist")

    links = helpers.get_links()
    titles = [title for title, _ in links.items()]
    assert "TEST_TITLE" in ' '.join(titles)
    with app.test_request_context():
        flask.session['username'] = '******'
        helpers.change_lock_status("TEST TITLE", True)
        assert helpers.is_locked("TEST TITLE")

        helpers.change_lock_status("TEST TITLE", False)
        assert not helpers.is_locked("TEST TITLE")
    client.get(flask.url_for('uploads.display',
                             url="TEST_TITLE")).status_code == 200
    helpers.rename_title('TEST_TITLE', 'ANOTHER_Title')

    links = helpers.get_links()
    titles = [title for title, _ in links.items()]
    assert "TEST_TITLE" not in ' '.join(titles)
    assert "ANOTHER_Title" in ' '.join(titles)

    client.get(flask.url_for('uploads.display',
                             url="ANOTHER Title")).status_code == 200
    assert "BLAHBLAH" == helpers.read_markdown('ANOTHER_Title')
    helpers.remove_file_from_db("ANOTHER_Title")
Esempio n. 2
0
def close_page():
    """
    Call to change the status of the locks when one exits a page
    """
    title = flask.request.form['title']
    helpers.change_lock_status(title, False)
    return ""
Esempio n. 3
0
def keep_alive_page():
    """
    Call to update the last access time for a page
    """
    title = flask.request.form['title']
    if helpers.check_edit_page_permission():
        helpers.change_lock_status(title, True)
    return ""
Esempio n. 4
0
def editor():
    '''
    Returns the editor page where users can create and edit
    existing pages
    '''
    input_text = ""
    title = flask.request.args.get('title')
    if title != None:
        input_text = helpers.read_markdown(title)
        load_default = False
    else:
        title = "New Page"
        load_default = True
    if helpers.is_locked(
            title, load_default) or not helpers.check_edit_page_permission():
        return flask.abort(403)
    helpers.change_lock_status(title, True, load_default)
    return flask.render_template('editor_page.html',
                                 input_text=input_text,
                                 title=title)
Esempio n. 5
0
def test_text_editor_page(client):
    with client.session_transaction() as sess:
        sess['username'] = '******'
    with app.test_request_context():
        flask.session['username'] = '******'
        helpers.create_page_in_database(
            "Some really really really interesting title",
            "nothing to see here")
        helpers.change_lock_status(
            "Some really really really interesting title", False)
        assert not helpers.is_locked(
            "Some really really really interesting title")
        helpers.create_page_in_database("Some less interesting title",
                                        "or is there")
        helpers.change_lock_status("Some less interesting title", True)
        assert helpers.is_locked("Some less interesting title")
        helpers.change_lock_status("default", True, default=True)
        assert not helpers.is_locked("default")

    rv = client.get(
        flask.url_for('editor.editor',
                      title="Some really really really interesting title"))
    assert rv.status_code == 200
    assert b'Some really really really interesting title' in rv.data