Exemplo n.º 1
0
def test_create_creator_with_roles(use_test_db, test_creator_dict):
    test_work_id = testing_utils.create_fake_work()['id']
    test_creator_dict['roles'] = {'illustrator': [test_work_id]}
    new_test_creator = logic.create_creator(test_creator_dict)
    with session_scope() as session:
        created_role_id = session.query(Role)\
            .filter_by(work_id=test_work_id, creator_id=new_test_creator['id'])\
            .first().id
    assert new_test_creator['roles'] == [created_role_id]
Exemplo n.º 2
0
def test_update_creator_with_roles(use_test_db, test_creator_dict):
    test_creator_id = testing_utils.create_fake_creator()['id']
    test_work_id = testing_utils.create_fake_work()['id']
    test_creator_dict['roles'] = {'illustrator': [test_work_id], 'author': [test_work_id]}
    test_creator_dict['related_creators'] = [test_creator_id]
    new_test_creator = logic.create_creator(test_creator_dict)

    test_creator_dict['aliases'].pop()
    test_creator_dict['roles'].pop('illustrator')
    updated_test_creator = logic.update_creator(new_test_creator['id'], test_creator_dict)
    with session_scope() as session:
        created_role = session.query(Role)\
            .filter_by(work_id=test_work_id, creator_id=new_test_creator['id'])\
            .first().to_dict()
        test_work = session.query(Work).filter_by(id=test_work_id).first().to_dict()
    assert test_work['roles'] == updated_test_creator['roles']
    assert test_creator_dict['aliases'] == updated_test_creator['aliases']
    assert 'author' == created_role['role']
Exemplo n.º 3
0
def test_create_creator(use_test_db, test_creator_dict):
    new_test_creator = logic.create_creator(test_creator_dict)
    assert new_test_creator['name'] == test_creator_dict['name']
    assert test_creator_dict['aliases'][0] in new_test_creator['aliases']
Exemplo n.º 4
0
Arquivo: app.py Projeto: kennydo/medea
def creators():
    model_data = api_to_model_dict(request.get_json())
    response = logic.create_creator(model_data)
    return {'creator': response}, 201