def test_earliest_date_from_thesis_date(): with_thesis_date = InspireRecord({'thesis': {'date': '2008'}}) earliest_date(None, with_thesis_date) expected = '2008' result = with_thesis_date['earliest_date'] assert expected == result
def test_earliest_date_from_imprints_date(): with_imprints_date = InspireRecord({'imprints': [{'date': '2014-09-26'}]}) earliest_date(None, with_imprints_date) expected = '2014-09-26' result = with_imprints_date['earliest_date'] assert expected == result
def test_earliest_date_from_preprint_date(): with_preprint_date = InspireRecord({'preprint_date': '2014-05-29'}) earliest_date(None, with_preprint_date) expected = '2014-05-29' result = with_preprint_date['earliest_date'] assert expected == result
def test_earliest_date_from_publication_info_year(): with_publication_info_year = InspireRecord( {'publication_info': [{ 'year': '2014' }]}) earliest_date(None, with_publication_info_year) expected = '2014' result = with_publication_info_year['earliest_date'] assert expected == result
def test_earliest_date_from_creation_modification_date_creation_date(): with_creation_modification_date_creation_date = InspireRecord( {'creation_modification_date': [{ 'creation_date': '2015-11-04' }]}) earliest_date(None, with_creation_modification_date_creation_date) expected = '2015-11-04' result = with_creation_modification_date_creation_date['earliest_date'] assert expected == result
def test_earliest_date_from_thesis_info_defense_date(): schema = load_schema('hep') subschema = schema['properties']['thesis_info'] record = {'thesis_info': {'defense_date': '2012-06-01'}} assert validate(record['thesis_info'], subschema) is None earliest_date(None, record) expected = '2012-06-01' result = record['earliest_date'] assert expected == result
def test_earliest_date_from_preprint_date(): schema = load_schema('hep') subschema = schema['properties']['preprint_date'] record = {'preprint_date': '2014-05-29'} assert validate(record['preprint_date'], subschema) is None earliest_date(None, record) expected = '2014-05-29' result = record['earliest_date'] assert expected == result
def test_earliest_date_from_imprints_date(): schema = load_schema('hep') subschema = schema['properties']['imprints'] record = {'imprints': [{'date': '2014-09-26'}]} assert validate(record['imprints'], subschema) is None earliest_date(None, record) expected = '2014-09-26' result = record['earliest_date'] assert expected == result
def test_earliest_date_from_legacy_creation_date(): schema = load_schema('hep') subschema = schema['properties']['legacy_creation_date'] record = {'legacy_creation_date': '2015-11-04'} assert validate(record['legacy_creation_date'], subschema) is None earliest_date(None, record) expected = '2015-11-04' result = record['earliest_date'] assert expected == result
def test_earliest_date_from_publication_info_year(): schema = load_schema('hep') subschema = schema['properties']['publication_info'] record = { 'publication_info': [ { 'year': 2014 }, ], } assert validate(record['publication_info'], subschema) is None earliest_date(None, record) expected = '2014' result = record['earliest_date'] assert expected == result