def test_literature_and_reference_builder():
    hep_builder = api.LiteratureBuilder()
    hep_builder.add_document_type('article')
    hep_builder.add_title('Work Title')

    ref_builder = api.ReferenceBuilder()
    ref_builder.add_title('Cited Work')
    ref_builder.add_author('Smith, J.', 'author')

    hep_builder.add_reference(ref_builder.obj)

    assert hep_builder.validate_record() is None
def test_literature_builder_valid_record(input_data_hep, expected_data_hep):

    builder = api.LiteratureBuilder('submitter')

    builder.add_abstract(abstract=input_data_hep['abstract'], )
    builder.add_arxiv_eprint(
        arxiv_id=input_data_hep['arxiv_id'],
        arxiv_categories=input_data_hep['arxiv_categories'])
    builder.add_doi(doi=input_data_hep['doi'],
                    material=input_data_hep['material'])
    author = builder.make_author(
        full_name=input_data_hep['full_name'],
        affiliations=input_data_hep['affiliations'],
        roles=input_data_hep['roles'],
        raw_affiliations=input_data_hep['raw_affiliations'],
    )
    builder.add_author(author)

    builder.add_inspire_categories(
        subject_terms=input_data_hep['subject_terms'],
        source=input_data_hep['source_categories'])
    builder.add_private_note(private_notes=input_data_hep['private_notes'])
    builder.add_publication_info(
        year=input_data_hep['year'],
        cnum=input_data_hep['cnum'],
        artid=input_data_hep['artid'],
        page_end=input_data_hep['page_end'],
        page_start=input_data_hep['page_start'],
        journal_issue=input_data_hep['journal_issue'],
        journal_title=input_data_hep['journal_title'],
        journal_volume=input_data_hep['journal_volume'],
        material=input_data_hep['material'],
        parent_record=input_data_hep['parent_record'])
    builder.add_preprint_date(preprint_date=input_data_hep['preprint_date'])
    builder.add_thesis(defense_date=input_data_hep['defense_date'],
                       degree_type=input_data_hep['degree_type'],
                       institution=input_data_hep['institution'],
                       date=input_data_hep['date'])
    builder.add_accelerator_experiments_legacy_name(
        legacy_name=input_data_hep['legacy_name'])
    builder.add_language(language=input_data_hep['language'])
    builder.add_license(url=input_data_hep['license_url'],
                        license=input_data_hep['license'],
                        imposing=input_data_hep['license_imposing'],
                        material=input_data_hep['material'])
    builder.add_public_note(public_note=input_data_hep['public_note'])
    builder.add_title(
        title=input_data_hep['title'],
        subtitle=input_data_hep['subtitle'],
    )
    builder.add_title_translation(title=input_data_hep['title'],
                                  language=input_data_hep['language'])
    builder.add_url(url=input_data_hep['url'])
    builder.add_report_number(report_number=input_data_hep['report_number'])
    builder.add_collaboration(collaboration=input_data_hep['collaboration'])
    builder.add_acquisition_source(
        method=input_data_hep['method'],
        submission_number=input_data_hep['submission_number'],
        internal_uid=input_data_hep['internal_uid'],
        email=input_data_hep['email'],
        orcid=input_data_hep['orcid'])
    builder.add_document_type(document_type=input_data_hep['document_type'])
    builder.add_copyright(material=input_data_hep['material'],
                          year=input_data_hep['year'],
                          holder=input_data_hep['holder'],
                          statement=input_data_hep['statement'],
                          url=input_data_hep['copyright_url'])
    builder.add_number_of_pages(
        number_of_pages=input_data_hep['number_of_pages'])
    builder.add_collection(collection=input_data_hep['collection'])
    builder.add_publication_type(
        publication_type=input_data_hep['publication_type'])
    builder.add_book_edition(edition=input_data_hep['book_edition'])
    builder.add_book(publisher=input_data_hep['publisher'],
                     place=input_data_hep['place'],
                     date=input_data_hep['imprint_date'])
    builder.add_book_series(title=input_data_hep['title'],
                            volume=input_data_hep['book_volume'])
    for isbn in input_data_hep['isbns']:
        builder.add_isbn(isbn=isbn['code'], medium=isbn['type_of_isbn'])
    builder.set_core(core=input_data_hep['core'])
    builder.set_refereed(refereed=input_data_hep['refereed'])
    builder.set_withdrawn(withdrawn=input_data_hep['withdrawn'])
    builder.set_citeable(citeable=input_data_hep['citeable'])
    builder.set_curated(curated=input_data_hep['curated'])
    assert builder.validate_record() is None
    assert builder.record == expected_data_hep