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


Python Record.validate方法代码示例

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


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

示例1: test_minimal_record

# 需要导入模块: from invenio_records import Record [as 别名]
# 或者: from invenio_records.Record import validate [as 别名]
def test_minimal_record(app, minimal_record):
    """Test minimal record."""
    expected = {
        u'publication_distribution_imprint': [{
            'date_of_publication_distribution': (
                datetime.utcnow().date().isoformat())
        }],
        u'control_number': '123',
        u'information_relating_to_copyright_status': {
            'copyright_status': 'open'
        },
        u'summary': {
            'summary': 'My description'
        },
        u'main_entry_personal_name': {
            'personal_name': 'Test'
        },
        u'resource_type': {
            'type': 'software'
        },
        u'title_statement': {
            'title': 'Test'
        }
    }

    # Create record and pid.
    record = Record(minimal_record)
    pid = PersistentIdentifier(pid_type='recid', pid_value='2')
    assert record.validate() is None

    data = marcxml_v1.schema_class().dump(marcxml_v1.preprocess_record(
        pid=pid,
        record=record)).data
    assert_dict(expected, data)

    marcxml_v1.serialize(pid=pid, record=record)
开发者ID:krzysztof,项目名称:zenodo,代码行数:38,代码来源:test_schemas_marcxml.py

示例2: test_full_record

# 需要导入模块: from invenio_records import Record [as 别名]
# 或者: from invenio_records.Record import validate [as 别名]

#.........这里部分代码省略.........
                u'relationship_information': u'cites',
            },
            {
                u'main_entry_heading': u'1234.4321',
                u'note': u'arxiv',
                u'relationship_information': u'cites',
            },
            {
                u'main_entry_heading': u'Staszkowka',
                u'edition': u'Jol',
                u'title': u'Bum',
                u'related_parts': u'1-2',
                u'international_standard_book_number': u'978-0201633610',
            },
        ],
        u'other_standard_identifier': [
            {
                u'standard_number_or_code': u'10.1234/foo.bar',
                u'source_of_number_or_code': u'doi',
            },
            {
                u'standard_number_or_code': (
                    u'urn:lsid:ubio.org:namebank:11815'),
                u'source_of_number_or_code': u'lsid',
                u'qualifying_information': u'alternateidentifier',
            },
            {
                u'standard_number_or_code': u'2011ApJS..192...18K',
                u'source_of_number_or_code': u'issn',
                u'qualifying_information': u'alternateidentifier',
            },
            {
                u'standard_number_or_code': u'10.1234/alternate.doi',
                u'source_of_number_or_code': u'doi',
                u'qualifying_information': u'alternateidentifier',
            }
        ],
        u'references': [
            {
                u'raw_reference': u'Doe, John et al (2012). Some title. '
                'Zenodo. 10.5281/zenodo.12'
            }, {
                u'raw_reference': u'Smith, Jane et al (2012). Some title. '
                'Zenodo. 10.5281/zenodo.34'
            }
        ],
        u'added_entry_meeting_name': [{
            u'date_of_meeting': u'23-25 June, 2014',
            u'meeting_name_or_jurisdiction_name_as_entry_element':
            u'The 13th Biennial HITRAN Conference',
            u'number_of_part_section_meeting': u'VI',
            u'miscellaneous_information': u'HITRAN13',
            u'name_of_part_section_of_a_work': u'1',
            u'location_of_meeting':
            u'Harvard-Smithsonian Center for Astrophysics'
        }],
        u'conference_url': 'http://hitran.org/conferences/hitran-13-2014/',
        u'dissertation_note': {
            u'name_of_granting_institution': u'I guess important',
        },
        u'journal': {
            'issue': '2',
            'pages': '20',
            'volume': '20',
            'title': 'Bam',
            'year': '2014',
        },
        # missing files
        # missing language
        u'embargo_date': '0900-12-31',
        u'_oai': {
            u'sets': [u'user-zenodo', u'user-ecfunded'],
            u'id': u'oai:zenodo.org:1'
        }
    }

    # Add embargo date and OAI-PMH set information.
    full_record['embargo_date'] = '0900-12-31'
    full_record['_oai'] = {
        "id": "oai:zenodo.org:1",
        "sets": ["user-zenodo", "user-ecfunded"]
    }

    # Create record and PID.
    record = Record(full_record)
    pid = PersistentIdentifier(pid_type='recid', pid_value='2')
    assert record.validate() is None

    # Dump MARC21 JSON structure and compare against expected JSON.
    preprocessed_record = marcxml_v1.preprocess_record(record=record, pid=pid)
    # - needed since we don't create a record backed by DB model.
    preprocessed_record['updated'] = now.isoformat()

    assert_dict(
        expected,
        marcxml_v1.schema_class().dump(preprocessed_record).data
    )

    # Assert that we can output MARCXML.
    marcxml_v1.serialize(record=record, pid=pid)
开发者ID:krzysztof,项目名称:zenodo,代码行数:104,代码来源:test_schemas_marcxml.py


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