예제 #1
0
파일: test_logic.py 프로젝트: kennydo/medea
def test_update_work_with_roles(use_test_db, test_work_dict):
    new_test_work = logic.create_work(test_work_dict)
    test_creator_id = testing_utils.create_fake_creator()['id']
    test_work_dict['roles'] = {'illustrator': [test_creator_id]}
    updated_test_work = logic.update_work(test_work_dict['id'], test_work_dict)
    assert new_test_work['id'] == updated_test_work['id']
    assert updated_test_work['roles'] == [test_creator_id]
예제 #2
0
파일: test_logic.py 프로젝트: kennydo/medea
def test_create_work_with_roles(use_test_db, test_work_dict):
    test_creator_id = testing_utils.create_fake_creator()['id']
    test_work_dict['roles'] = {'illustrator': [test_creator_id]}
    new_test_work = logic.create_work(test_work_dict)
    with session_scope() as session:
        created_role_id = session.query(Role)\
            .filter_by(work_id=new_test_work['id'], creator_id=test_creator_id)\
            .first().id
    assert new_test_work['roles'] == [created_role_id]
예제 #3
0
파일: test_logic.py 프로젝트: kennydo/medea
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']