def test_earliest_date_from_imprints_date():
    with_imprints_date = Record({"imprints": [{"date": "2014-09-26"}]})
    earliest_date(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 = Record({'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 = Record({"publication_info": [{"year": "2014"}]})
    earliest_date(with_publication_info_year)

    expected = "2014"
    result = with_publication_info_year["earliest_date"]

    assert expected == result
def test_earliest_date_from_preprint_date():
    with_preprint_date = Record({"preprint_date": "2014-05-29"})
    earliest_date(with_preprint_date)

    expected = "2014-05-29"
    result = with_preprint_date["earliest_date"]

    assert expected == result
def test_earliest_date_from_preprint_date():
    with_preprint_date = Record({'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_imprints_date():
    with_imprints_date = Record({'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_thesis_date():
    with_thesis_date = Record({'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_thesis_defense_date():
    with_thesis_defense_date = Record({"thesis": {"defense_date": "2012-06-01"}})
    earliest_date(with_thesis_defense_date)

    expected = "2012-06-01"
    result = with_thesis_defense_date["earliest_date"]

    assert expected == result
def test_earliest_date_from_thesis_defense_date():
    with_thesis_defense_date = Record({
        'thesis': {'defense_date': '2012-06-01'}
    })
    earliest_date(None, with_thesis_defense_date)

    expected = '2012-06-01'
    result = with_thesis_defense_date['earliest_date']

    assert expected == result
def test_earliest_date_from_creation_modification_date_creation_date():
    with_creation_modification_date_creation_date = Record(
        {"creation_modification_date": [{"creation_date": "2015-11-04"}]}
    )
    earliest_date(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_creation_modification_date_creation_date():
    with_creation_modification_date_creation_date = Record(
        {'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_publication_info_year():
    with_publication_info_year = Record(
        {'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_publication_info_year():
    with_publication_info_year = Record({
        '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_thesis_date():
    with_thesis_date = Record({
        'thesis': [
            {'date': '2008'}
        ]
    })
    earliest_date(with_thesis_date)

    expected = '2008'
    result = with_thesis_date['earliest_date']

    assert expected == result
def test_earliest_date_from_creation_modification_date_creation_date():
    with_creation_modification_date_creation_date = Record({
        '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_imprints_date():
    with_imprints_date = Record({
        '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(full_record, pub_info, creation_modification_date,
                       imprints, thesis):
    """Test earliest_date record enhancer."""
    earliest_date(full_record)
    earliest_date(pub_info)
    earliest_date(creation_modification_date)
    earliest_date(imprints)
    earliest_date(thesis)
    assert full_record['earliest_date'] == '2008'
    assert pub_info['earliest_date'] == '2014'
    assert creation_modification_date['earliest_date'] == '2015-11-04'
    assert imprints['earliest_date'] == '2014-09-26'
    assert thesis['earliest_date'] == '2008'