def test_populate_inspire_document_type_doc_type_from_document_type_book_chapter( ): json_dict = {'document_type': ['book chapter']} populate_inspire_document_type(None, json_dict) assert json_dict['facet_inspire_doc_type'] == ['book chapter']
def test_populate_inspire_document_type_from_publication_type(): schema = load_schema('hep') document_type_schema = schema['properties']['document_type'] publication_type_schema = schema['properties']['publication_type'] record = { '$schema': 'http://localhost:5000/records/schemas/hep.json', 'document_type': [ 'article', ], 'publication_type': [ 'introductory', ], } assert validate(record['document_type'], document_type_schema) is None assert validate(record['publication_type'], publication_type_schema) is None populate_inspire_document_type(None, record) expected = [ 'article', 'introductory', ] result = record['facet_inspire_doc_type'] assert expected == result
def test_populate_inspire_document_type_doc_type_from_document_type_conference_paper( ): json_dict = {'document_type': ['conference paper']} populate_inspire_document_type(None, json_dict) assert json_dict['facet_inspire_doc_type'] == ['conference paper']
def test_populate_inspire_document_type_doc_type_from_document_type_proceedings( ): json_dict = {'document_type': ['proceedings']} populate_inspire_document_type(None, json_dict) assert json_dict['facet_inspire_doc_type'] == ['proceedings']
def test_populate_inspire_document_type_no_doc_type_when_collections_empty(): json_dict = { 'collections': [], } populate_inspire_document_type(None, json_dict) assert json_dict['facet_inspire_doc_type'] == ['preprint']
def test_populate_inspire_document_type_doc_type_from_primary_conferencepaper(): json_dict = { 'collections': [ {'primary': 'conferencepaper'}, ], } populate_inspire_document_type(None, json_dict) assert json_dict['facet_inspire_doc_type'] == ['conference paper']
def test_populate_inspire_document_type_doc_type_from_primary_published(): json_dict = { 'collections': [ {'primary': 'published'}, ], } populate_inspire_document_type(None, json_dict) assert json_dict['facet_inspire_doc_type'] == ['peer reviewed']
def test_populate_inspire_document_type_no_doc_type_when_no_primary(): json_dict = { 'collections': [ {'not-primary': 'foo'}, ], } populate_inspire_document_type(None, json_dict) assert json_dict['facet_inspire_doc_type'] == ['preprint']
def test_populate_inspire_document_type_doc_type_from_primary_activityreport(): json_dict = { 'collections': [ {'primary': 'activityreport'}, ], } populate_inspire_document_type(None, json_dict) assert json_dict['facet_inspire_doc_type'] == ['activity report']
def test_populate_inspire_document_type_doc_type_from_primary_note(): json_dict = { 'collections': [ {'primary': 'note'}, ], } populate_inspire_document_type(None, json_dict) assert json_dict['facet_inspire_doc_type'] == ['note']
def test_populate_inspire_document_type_doc_type_from_primary_published(): json_dict = { 'collections': [ { 'primary': 'published' }, ], } populate_inspire_document_type(None, json_dict) assert json_dict['facet_inspire_doc_type'] == ['peer reviewed']
def test_populate_inspire_document_type_doc_type_from_primary_activityreport(): json_dict = { 'collections': [ { 'primary': 'activityreport' }, ], } populate_inspire_document_type(None, json_dict) assert json_dict['facet_inspire_doc_type'] == ['activity report']
def test_populate_inspire_document_type_no_doc_type_when_no_primary(): json_dict = { 'collections': [ { 'not-primary': 'foo' }, ], } populate_inspire_document_type(None, json_dict) assert json_dict['facet_inspire_doc_type'] == ['preprint']
def test_populate_inspire_document_type_doc_type_from_primary_note(): json_dict = { 'collections': [ { 'primary': 'note' }, ], } populate_inspire_document_type(None, json_dict) assert json_dict['facet_inspire_doc_type'] == ['note']
def test_populate_inspire_document_type_doc_type_from_primary_lectures(): json_dict = { 'collections': [ {'primary': 'lectures'}, ], } populate_inspire_document_type(None, json_dict) assert json_dict['facet_inspire_doc_type'] == [ 'preprint', 'lectures', ]
def test_populate_inspire_document_type_doc_type_from_primary_conferencepaper( ): json_dict = { 'collections': [ { 'primary': 'conferencepaper' }, ], } populate_inspire_document_type(None, json_dict) assert json_dict['facet_inspire_doc_type'] == ['conference paper']
def test_populate_inspire_document_type_doc_type_from_refereed(): json_dict = { 'document_type': [ 'article', ], 'refereed': True, } populate_inspire_document_type(None, json_dict) assert json_dict['facet_inspire_doc_type'] == [ 'article', 'peer reviewed', ]
def test_populate_inspire_document_type_with_page_start_and_artid(): json_dict = { 'collections': [], 'publication_info': [ { 'page_start': 'foo', 'artid': 'bar', }, ], } populate_inspire_document_type(None, json_dict) assert json_dict['facet_inspire_doc_type'] == []
def test_populate_inspire_document_type_doc_type_from_publication_type_lectures( ): json_dict = { 'document_type': [ 'article', ], 'publication_type': ['lectures'], } populate_inspire_document_type(None, json_dict) assert json_dict['facet_inspire_doc_type'] == [ 'article', 'lectures', ]
def test_populate_inspire_document_type_doc_type_from_primary_lectures(): json_dict = { 'collections': [ { 'primary': 'lectures' }, ], } populate_inspire_document_type(None, json_dict) assert json_dict['facet_inspire_doc_type'] == [ 'preprint', 'lectures', ]
def test_populate_inspire_document_type_no_preprint_if_valid_primary(): json_dict = { 'collections': [ {'primary': 'published'}, ], 'publication_info': [ { 'not-page_start': 'foo', 'not-artid': 'bar', }, ], } populate_inspire_document_type(None, json_dict) assert json_dict['facet_inspire_doc_type'] == ['peer reviewed']
def test_populate_inspire_document_type_doc_type_from_publication_type_introductory( ): json_dict = { 'document_type': [ 'article', ], 'publication_type': [ 'introductory', ], } populate_inspire_document_type(None, json_dict) assert json_dict['facet_inspire_doc_type'] == [ 'article', 'introductory', ]
def test_populate_inspire_document_type_from_document_type(): schema = load_schema('hep') subschema = schema['properties']['document_type'] record = { '$schema': 'http://localhost:5000/records/schemas/hep.json', 'document_type': ['thesis'], } assert validate(record['document_type'], subschema) is None populate_inspire_document_type(None, record) expected = [ 'thesis', ] result = record['facet_inspire_doc_type'] assert expected == result
def test_populate_inspire_document_type_no_preprint_if_valid_primary(): json_dict = { 'collections': [ { 'primary': 'published' }, ], 'publication_info': [ { 'not-page_start': 'foo', 'not-artid': 'bar', }, ], } populate_inspire_document_type(None, json_dict) assert json_dict['facet_inspire_doc_type'] == ['peer reviewed']
def test_populate_inspire_document_type_from_refereed(): schema = load_schema('hep') document_type_schema = schema['properties']['document_type'] refereed_schema = schema['properties']['refereed'] record = { '$schema': 'http://localhost:5000/records/schemas/hep.json', 'document_type': [ 'article', ], 'refereed': True, } assert validate(record['document_type'], document_type_schema) is None assert validate(record['refereed'], refereed_schema) is None populate_inspire_document_type(None, record) expected = [ 'article', 'peer reviewed', ] result = record['facet_inspire_doc_type'] assert expected == result
def test_populate_inspire_document_type_does_nothing_if_record_is_not_literature(): record = {'$schema': 'http://localhost:5000/schemas/records/other.json'} populate_inspire_document_type(None, record) assert 'facet_inspire_doc_type' not in record
def test_populate_inspire_document_type_doc_type_from_document_type_report(): json_dict = {'document_type': ['report']} populate_inspire_document_type(None, json_dict) assert json_dict['facet_inspire_doc_type'] == ['report']
def test_populate_inspire_document_type_no_doc_type_when_no_collections(): json_dict = {} populate_inspire_document_type(None, json_dict) assert json_dict['facet_inspire_doc_type'] == []