当前位置: 首页>>代码示例>>Python>>正文


Python Deposit.create方法代码示例

本文整理汇总了Python中invenio_deposit.api.Deposit.create方法的典型用法代码示例。如果您正苦于以下问题:Python Deposit.create方法的具体用法?Python Deposit.create怎么用?Python Deposit.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在invenio_deposit.api.Deposit的用法示例。


在下文中一共展示了Deposit.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_deposit_index

# 需要导入模块: from invenio_deposit.api import Deposit [as 别名]
# 或者: from invenio_deposit.api.Deposit import create [as 别名]
def test_deposit_index(db, es):
    """Test update embargoed records."""
    deposit_index_name = 'deposits-records-record-v1.0.0'
    rec1 = Record.create({
        'title': 'One',
        '_deposit': {
            'status': 'published',
            'pid': {
                'type': 'recid',
                'value': '1'
            }
        }
    })
    PersistentIdentifier.create(pid_type='recid', pid_value='1',
                                status=PIDStatus.REGISTERED,
                                object_uuid=rec1.id, object_type='rec')
    Deposit.create({
        '_deposit': {
            'status': 'published',
            'pid': {
                'type': 'recid',
                'value': '1'
            }
        }
    })
    db.session.commit()
    current_search.flush_and_refresh(deposit_index_name)
    res = current_search.client.search(index=deposit_index_name)
    # Make sure the 'title' was indexed from record
    assert res['hits']['hits'][0]['_source']['title'] == 'One'
开发者ID:lnielsen,项目名称:zenodo,代码行数:32,代码来源:test_deposit_index.py

示例2: test_created_by_population

# 需要导入模块: from invenio_deposit.api import Deposit [as 别名]
# 或者: from invenio_deposit.api.Deposit import create [as 别名]
def test_created_by_population(app, db, users):
    """Test created_by gets populated correctly."""
    record = {
        'title': 'fuu'
    }

    deposit = Deposit.create(record)
    assert 'created_by' not in deposit['_deposit']

    with app.test_request_context():
        login_user(users[0])
        deposit = Deposit.create(record)
        assert deposit['_deposit']['created_by'] == users[0].id
开发者ID:nharraud,项目名称:invenio-deposit,代码行数:15,代码来源:test_views_rest_files.py

示例3: test_schemas

# 需要导入模块: from invenio_deposit.api import Deposit [as 别名]
# 或者: from invenio_deposit.api.Deposit import create [as 别名]
def test_schemas(app, db, fake_schemas):
    """Test schema URL transformations."""
    deposit = Deposit.create({})
    assert "http://localhost/schemas/deposits/deposit-v1.0.0.json" == deposit["$schema"]

    assert "http://localhost/schemas/deposit-v1.0.0.json" == deposit.record_schema

    assert "http://localhost/schemas/deposits/test-v1.0.0.json" == deposit.build_deposit_schema(
        {"$schema": "http://localhost/schemas/test-v1.0.0.json"}
    )

    with pytest.raises(RefResolutionError):
        Deposit.create({"$schema": "http://localhost/schemas/deposits/invalid.json"})
开发者ID:hachreak,项目名称:invenio-deposit,代码行数:15,代码来源:test_api.py

示例4: test_created_by_population

# 需要导入模块: from invenio_deposit.api import Deposit [as 别名]
# 或者: from invenio_deposit.api.Deposit import create [as 别名]
def test_created_by_population(api, users):
    """Test created_by gets populated correctly."""
    record = {
        'title': 'fuu'
    }

    deposit = Deposit.create(record)
    assert 'created_by' not in deposit['_deposit']

    with api.test_request_context():
        datastore = api.extensions['security'].datastore
        login_user(datastore.find_user(email=users[0]['email']))
        deposit = Deposit.create(record)
        assert deposit['_deposit']['created_by'] == users[0]['id']
开发者ID:tiborsimko,项目名称:invenio-deposit,代码行数:16,代码来源:test_views_rest_files.py

示例5: test_publish_revision_changed_not_mergeable

# 需要导入模块: from invenio_deposit.api import Deposit [as 别名]
# 或者: from invenio_deposit.api.Deposit import create [as 别名]
def test_publish_revision_changed_not_mergeable(app, location,
                                                fake_schemas):
    """Try to Publish and someone change the deposit in the while."""
    # create a deposit
    deposit = Deposit.create({"metadata": {
        "title": "title-1",
    }})
    deposit.commit()
    db.session.commit()
    # publish
    deposit.publish()
    db.session.commit()
    # edit
    deposit = deposit.edit()
    db.session.commit()
    # simulate a externally modification
    rid, record = deposit.fetch_published()
    rev_id = record.revision_id
    record.update({'metadata': {
        "title": "title-2.1",
    }})
    record.commit()
    db.session.commit()
    assert rev_id != record.revision_id
    # edit again and check the merging
    deposit.update({"metadata": {
        "title": "title-2.2",
    }})
    deposit.commit()
    with pytest.raises(MergeConflict):
        deposit.publish()
开发者ID:tiborsimko,项目名称:invenio-deposit,代码行数:33,代码来源:test_api.py

示例6: test_publish_revision_changed_mergeable

# 需要导入模块: from invenio_deposit.api import Deposit [as 别名]
# 或者: from invenio_deposit.api.Deposit import create [as 别名]
def test_publish_revision_changed_mergeable(app, db, location, fake_schemas):
    """Try to Publish and someone change the deposit in the while."""
    # create a deposit
    deposit = Deposit.create({"metadata": {"title": "title-1"}})
    deposit.commit()
    db.session.commit()
    # publish
    deposit.publish()
    db.session.commit()
    # edit
    deposit = deposit.edit()
    db.session.commit()
    # simulate a externally modification
    rid, record = deposit.fetch_published()
    rev_id = record.revision_id
    # try to change metadata
    record.update({"metadata": {"title": "title-1", "poster": "myposter"}})
    record.commit()
    db.session.commit()
    assert rev_id != record.revision_id
    # edit again and check the merging
    deposit.update({"metadata": {"title": "title-1", "description": "mydesc"}})
    deposit.commit()
    deposit.publish()
    db.session.commit()
    # check if is properly merged
    did, deposit = deposit.fetch_published()
    assert deposit["metadata"]["title"] == "title-1"
    assert deposit["metadata"]["poster"] == "myposter"
    assert deposit["metadata"]["description"] == "mydesc"
    assert deposit["$schema"] == "http://localhost/schemas/deposit-v1.0.0.json"
开发者ID:hachreak,项目名称:invenio-deposit,代码行数:33,代码来源:test_api.py

示例7: records

# 需要导入模块: from invenio_deposit.api import Deposit [as 别名]
# 或者: from invenio_deposit.api.Deposit import create [as 别名]
def records():
    """Load records."""
    import pkg_resources
    import uuid
    from flask_login import login_user, logout_user
    from dojson.contrib.marc21 import marc21
    from dojson.contrib.marc21.utils import create_record, split_blob
    from invenio_accounts.models import User
    from invenio_deposit.api import Deposit

    users = User.query.all()

    # pkg resources the demodata
    data_path = pkg_resources.resource_filename(
        'invenio_records', 'data/marc21/bibliographic.xml'
    )
    with open(data_path) as source:
        with current_app.test_request_context():
            indexer = RecordIndexer()
            with db.session.begin_nested():
                for index, data in enumerate(split_blob(source.read()),
                                             start=1):
                    login_user(users[index % len(users)])
                    # do translate
                    record = marc21.do(create_record(data))
                    # create record
                    indexer.index(Deposit.create(record))
                    logout_user()
            db.session.commit()
开发者ID:techoutlooks,项目名称:invenio-deposit,代码行数:31,代码来源:app.py

示例8: test_schemas

# 需要导入模块: from invenio_deposit.api import Deposit [as 别名]
# 或者: from invenio_deposit.api.Deposit import create [as 别名]
def test_schemas(app, fake_schemas):
    """Test schema URL transformations."""
    deposit = Deposit.create({})
    assert 'http://localhost/schemas/deposits/deposit-v1.0.0.json' == \
        deposit['$schema']

    assert 'http://localhost/schemas/deposit-v1.0.0.json' == \
        deposit.record_schema

    assert 'http://localhost/schemas/deposits/test-v1.0.0.json' == \
        deposit.build_deposit_schema({
            '$schema': 'http://localhost/schemas/test-v1.0.0.json',
        })

    with pytest.raises(RefResolutionError):
        Deposit.create({
            '$schema': 'http://localhost/schemas/deposits/invalid.json',
        })
开发者ID:tiborsimko,项目名称:invenio-deposit,代码行数:20,代码来源:test_api.py

示例9: test_simple_flow

# 需要导入模块: from invenio_deposit.api import Deposit [as 别名]
# 或者: from invenio_deposit.api.Deposit import create [as 别名]
def test_simple_flow(app, fake_schemas, location):
    """Test simple flow of deposit states through its lifetime."""
    deposit = Deposit.create({})
    assert deposit['_deposit']['id']
    assert 'draft' == deposit.status
    assert 0 == deposit.revision_id

    deposit.publish()
    assert 'published' == deposit.status
    assert 1 == deposit.revision_id

    with pytest.raises(PIDInvalidAction):
        deposit.delete()
    with pytest.raises(PIDInvalidAction):
        deposit.clear()
    with pytest.raises(PIDInvalidAction):
        deposit.update(title='Revision 2')
    assert 'published' == deposit.status

    deposit = deposit.edit()
    assert 'draft' == deposit.status
    assert 2 == deposit.revision_id
    assert 0 == deposit['_deposit']['pid']['revision_id']

    with pytest.raises(PIDInvalidAction):
        deposit.edit()
    assert 'draft' == deposit.status

    deposit['title'] = 'Revision 1'
    deposit.publish()
    assert 'published' == deposit.status
    assert 3 == deposit.revision_id
    assert 0 == deposit['_deposit']['pid']['revision_id']

    deposit = deposit.edit()
    assert 'draft' == deposit.status
    assert 4 == deposit.revision_id
    assert 1 == deposit['_deposit']['pid']['revision_id']

    deposit['title'] = 'Revision 2'
    deposit.commit()
    assert 5 == deposit.revision_id

    (_, record) = deposit.fetch_published()
    record_schema_before = record['$schema']
    record_json = deepcopy(record.model.json)

    deposit = deposit.discard()
    assert 'published' == deposit.status
    assert 'Revision 1' == deposit['title']
    assert 6 == deposit.revision_id

    (_, record) = deposit.fetch_published()
    record_schema_after = record['$schema']
    assert record_schema_before == record_schema_after
    assert record_json == record.model.json
开发者ID:tiborsimko,项目名称:invenio-deposit,代码行数:58,代码来源:test_api.py

示例10: test_simple_flow

# 需要导入模块: from invenio_deposit.api import Deposit [as 别名]
# 或者: from invenio_deposit.api.Deposit import create [as 别名]
def test_simple_flow(app, db, fake_schemas, location):
    """Test simple flow of deposit states through its lifetime."""
    deposit = Deposit.create({})
    assert deposit["_deposit"]["id"]
    assert "draft" == deposit.status
    assert 0 == deposit.revision_id

    deposit.publish()
    assert "published" == deposit.status
    assert 1 == deposit.revision_id

    with pytest.raises(PIDInvalidAction):
        deposit.delete()
    with pytest.raises(PIDInvalidAction):
        deposit.clear()
    with pytest.raises(PIDInvalidAction):
        deposit.update(title="Revision 2")
    assert "published" == deposit.status

    deposit = deposit.edit()
    assert "draft" == deposit.status
    assert 2 == deposit.revision_id
    assert 0 == deposit["_deposit"]["pid"]["revision_id"]

    with pytest.raises(PIDInvalidAction):
        deposit.edit()
    assert "draft" == deposit.status

    deposit["title"] = "Revision 1"
    deposit.publish()
    assert "published" == deposit.status
    assert 3 == deposit.revision_id
    assert 0 == deposit["_deposit"]["pid"]["revision_id"]

    deposit = deposit.edit()
    assert "draft" == deposit.status
    assert 4 == deposit.revision_id
    assert 1 == deposit["_deposit"]["pid"]["revision_id"]

    deposit["title"] = "Revision 2"
    deposit.commit()
    assert 5 == deposit.revision_id

    (_, record) = deposit.fetch_published()
    record_schema_before = record["$schema"]
    record_json = deepcopy(record.model.json)

    deposit = deposit.discard()
    assert "published" == deposit.status
    assert "Revision 1" == deposit["title"]
    assert 6 == deposit.revision_id

    (_, record) = deposit.fetch_published()
    record_schema_after = record["$schema"]
    assert record_schema_before == record_schema_after
    assert record_json == record.model.json
开发者ID:hachreak,项目名称:invenio-deposit,代码行数:58,代码来源:test_api.py

示例11: test_create_deposit_cms_questionnaire_index

# 需要导入模块: from invenio_deposit.api import Deposit [as 别名]
# 或者: from invenio_deposit.api.Deposit import create [as 别名]
def test_create_deposit_cms_questionnaire_index(db, es, deposit_index):
    """Test if deposit cms questionnaire index is created."""
    deposit_index_name = deposit_index + '-' + 'cms-questionnaire-v0.0.1'

    Deposit.create({
        '$schema': 'https://localhost:5000/schemas/deposits/records/cms-questionnaire-v0.0.1.json',
        '_deposit': {
            'status': 'draft',
            'pid': {
                'type': 'recid',
                'value': '1'
            },
            'id': '0a7dac44ac234fd39d941fa14bae63c3'

        }
    })
    db.session.commit()
    current_search.flush_and_refresh(deposit_index_name)
    res = current_search.client.search(index=deposit_index_name)
    assert 'id' in res['hits']['hits'][0]['_source']['_deposit']
开发者ID:Kjili,项目名称:analysis-preservation.cern.ch,代码行数:22,代码来源:test_deposit_index.py

示例12: deposit

# 需要导入模块: from invenio_deposit.api import Deposit [as 别名]
# 或者: from invenio_deposit.api.Deposit import create [as 别名]
def deposit(app, es, users, location):
    """New deposit with files."""
    record = {
        'title': 'fuu'
    }
    with app.test_request_context():
        login_user(users[0])
        deposit = Deposit.create(record)
        deposit.commit()
        db_.session.commit()
    sleep(2)
    return deposit
开发者ID:drjova,项目名称:invenio-deposit,代码行数:14,代码来源:conftest.py

示例13: deposit

# 需要导入模块: from invenio_deposit.api import Deposit [as 别名]
# 或者: from invenio_deposit.api.Deposit import create [as 别名]
def deposit(app, es, users, location):
    """New deposit with files."""
    record = {
        'title': 'fuu'
    }
    with app.test_request_context():
        datastore = app.extensions['security'].datastore
        login_user(datastore.find_user(email=users[0]['email']))
        deposit = Deposit.create(record)
        deposit.commit()
        db.session.commit()
    sleep(2)
    return deposit
开发者ID:tiborsimko,项目名称:invenio-deposit,代码行数:15,代码来源:conftest.py

示例14: test_delete

# 需要导入模块: from invenio_deposit.api import Deposit [as 别名]
# 或者: from invenio_deposit.api.Deposit import create [as 别名]
def test_delete(app, db, fake_schemas):
    """Test simple delete."""
    deposit = Deposit.create({})
    pid = deposit.pid
    assert deposit['_deposit']['id']
    assert 'draft' == deposit['_deposit']['status']
    assert 0 == deposit.revision_id

    deposit.delete()

    with pytest.raises(NoResultFound):
        Deposit.get_record(deposit.id)

    with pytest.raises(PIDInvalidAction):
        deposit.publish(pid=pid)
开发者ID:techoutlooks,项目名称:invenio-deposit,代码行数:17,代码来源:test_api.py

示例15: test_delete

# 需要导入模块: from invenio_deposit.api import Deposit [as 别名]
# 或者: from invenio_deposit.api.Deposit import create [as 别名]
def test_delete(app, db, fake_schemas, location):
    """Test simple delete."""
    deposit = Deposit.create({})
    pid = deposit.pid
    assert deposit["_deposit"]["id"]
    assert "draft" == deposit.status
    assert 0 == deposit.revision_id

    deposit.delete()

    with pytest.raises(NoResultFound):
        Deposit.get_record(deposit.id)

    with pytest.raises(PIDInvalidAction):
        deposit.publish(pid=pid)
开发者ID:hachreak,项目名称:invenio-deposit,代码行数:17,代码来源:test_api.py


注:本文中的invenio_deposit.api.Deposit.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。