コード例 #1
0
ファイル: server.py プロジェクト: markijbema/hovercraft
def handle_list_presentations():
    cleanup(session['email'])

    presentations = storage.search_meta(session['email'])

    if not presentations:
        storage.store_presentation(session['email'], get_test_presentation())
        presentations = storage.search_meta(session['email'])
    if request.accept_mimetypes.accept_html:
        return render_template('list_presentations.html', presentations=presentations)
    elif request.accept_mimetypes.accept_json:
        return json_response(presentations)
    else:
        abort(406)
コード例 #2
0
ファイル: test_storage.py プロジェクト: markijbema/hovercraft
def test_search(email, presentation):
    pres = storage.store_presentation(email, presentation)
    new_presentation = deepcopy(presentation)
    del new_presentation['id']
    new_presentation['slides'] += new_presentation['slides']
    new_pres = storage.store_presentation(email, new_presentation)
    jsons = storage.search_json(email)
    presentations = map(json.loads, jsons)
    assert presentations in ([pres, new_pres], [new_pres, pres])
    pres_dict = dict((p['id'], p) for p in presentations)
    metas = storage.search_meta(email)
    for meta in metas:
        pres = pres_dict[meta['id']]
        for field in META_FIELDS:
            assert pres[field] == meta[field]
コード例 #3
0
ファイル: test_storage.py プロジェクト: markijbema/hovercraft
def test_create(email, presentation):
    pres = storage.store_presentation(email, presentation)
    assert pres['email'] == email
    assert pres['id']
    assert storage.get_meta(pres['id'], 'title') == pres['title']
    assert storage.get_meta(pres['id'], 'email') == pres['email']
    assert json.loads(storage.get_json(pres['id'])) == pres
コード例 #4
0
ファイル: test_storage.py プロジェクト: markijbema/hovercraft
def test_modify_wrong_id(email, presentation):
    presentation['id'] = uuid.uuid4().hex
    with pytest.raises(ValueError):
        storage.store_presentation(email, presentation)
コード例 #5
0
ファイル: test_storage.py プロジェクト: markijbema/hovercraft
def test_modify_wrong_email(email, presentation):
    storage.store_presentation(email, presentation)
    with pytest.raises(ValueError):
        storage.store_presentation(email + 'a', presentation)