コード例 #1
0
def test_get_twice_raises():
    msg_id = ed.add_message('TEST', '123456')

    ed.get_message(msg_id, '123456')

    with pytest.raises(ed.MessageNotFoundError):
        ed.get_message(msg_id, '123456')
コード例 #2
0
def test_can_get_multiple():
    msg1 = 'The quick brown fox jumps over the lazy dog'
    pin1 = '123789'

    msg2 = 'The five boxing wizards jump quickly'
    pin2 = '000000'

    msg_id1 = ed.add_message(msg1, pin1)
    msg_id2 = ed.add_message(msg2, pin2)

    assert ed.get_message(msg_id1, pin1) == msg1
    assert ed.get_message(msg_id2, pin2) == msg2
コード例 #3
0
def test_unicode_supported():
    msg = 'a\xac\u1234\u20ac\U00008000'
    pin = '123789'

    msg_id = ed.add_message(msg, pin)

    assert ed.get_message(msg_id, pin) == msg
コード例 #4
0
def test_can_get_added():
    msg = 'The quick brown fox jumps over the lazy dog'
    pin = '123789'

    msg_id = ed.add_message(msg, pin)

    assert ed.get_message(msg_id, pin) == msg
コード例 #5
0
def show(msg_id):
    if request.method == 'POST':
        try:
            body = get_message(msg_id, request.form['pin'])
        except MessageNotFoundError:
            return render_template('not_found.html', msg_id=msg_id), 404
        except IncorrectPinError:
            pass
        else:
            logger.info('SHOW {}'.format(msg_id))
            response = make_response(render_template('show.html', body=body))

            response.headers[
                'Cache-Control'] = 'no-cache, no-store, must-revalidate'
            response.headers['Pragma'] = 'no-cache'
            response.headers['Expires'] = '0'

            return response

    return render_template('pin.html',
                           csrf_token=session.get('_csrf_token', None))
コード例 #6
0
def test_non_existing_id_raises():
    with pytest.raises(ed.MessageNotFoundError):
        ed.get_message('NON-EXISTING-ID', '000000')
コード例 #7
0
def test_incorrect_pin_raises():
    msg_id = ed.add_message('TEST', '123456')

    with pytest.raises(ed.IncorrectPinError):
        ed.get_message(msg_id, '654321')