def test_format_date_when_datestruct_has_three_elements(): record = Record({}) cv_latex = Cv_latex(record) expected = 'Feb 2, 1993' result = cv_latex._format_date((1993, 2, 2)) assert expected == result
def test_parse_date_invalid_invenio_format(): record = Record({}) cv_latex = Cv_latex(record) expected = (1993, 2) result = cv_latex.parse_date('1993-02-ab') assert expected == result
def test_parse_date_full_invenio_format(): record = InspireRecord({}) cv_latex = Cv_latex(record) expected = (1993, 2, 2) result = cv_latex.parse_date('1993-02-02') assert expected == result
def test_format_date_when_datestruct_has_one_element(): record = Record({}) cv_latex = Cv_latex(record) expected = 1993 result = cv_latex._format_date((1993,)) assert expected == result
def test_parse_date_invalid_spires_format(): record = InspireRecord({}) cv_latex = Cv_latex(record) expected = (1993, 2) result = cv_latex.parse_date('199302ab') assert expected == result
def test_parse_date_full_spires_format(): record = Record({}) cv_latex = Cv_latex(record) expected = (1993, 2, 2) result = cv_latex.parse_date('19930202') assert expected == result
def test_parse_date_partial_spires_format_year_and_month(): record = Record({}) cv_latex = Cv_latex(record) expected = (1993, 2) result = cv_latex.parse_date('199302') assert expected == result
def test_format_date_when_datestruct_has_one_element(): record = Record({}) cv_latex = Cv_latex(record) expected = 1993 result = cv_latex._format_date((1993, )) assert expected == result
def test_format_date_when_datestruct_has_two_elements(): record = {} cv_latex = Cv_latex(record) expected = 'Feb 1993' result = cv_latex._format_date((1993, 2)) assert expected == result
def test_parse_date_supports_unicode_strings(): record = Record({}) cv_latex = Cv_latex(record) expected = (1993, 2, 2) result = cv_latex.parse_date(u'1993-02-02') assert expected == result
def test_parse_date_partial_spires_format_year_only(): record = Record({}) cv_latex = Cv_latex(record) expected = (1993,) result = cv_latex.parse_date('1993') assert expected == result
def test_parse_date_partial_spires_format_year_only(): record = Record({}) cv_latex = Cv_latex(record) expected = (1993, ) result = cv_latex.parse_date('1993') assert expected == result
def test_get_title_returns_empty_string_when_no_titles(): without_titles = Record({}) expected = '' result = Cv_latex(without_titles)._get_title() assert expected == result
def test_get_author_from_corporate_author_an_empty_list(): corporate_author_an_empty_list = Record({'corporate_author': []}) expected = [] result = Cv_latex(corporate_author_an_empty_list)._get_author() assert expected == result
def test_get_date_from_preprint_date_adds_zero_to_day(): preprint_date = Record({'preprint_date': '2014-10-1'}) expected = 'Oct 01, 2014' result = Cv_latex(preprint_date)._get_date() assert expected == result
def test_get_date_from_publication_info(): publication_info = Record({'publication_info': [{'year': '2011'}]}) expected = 2011 result = Cv_latex(publication_info)._get_date() assert expected == result
def test_get_date_from_preprint_date(): preprint_date = Record({'preprint_date': '2015-11-25'}) expected = 'Nov 25, 2015' result = Cv_latex(preprint_date)._get_date() assert expected == result
def test_get_url(): record = Record({'control_number': '1'}) expected = 'http://localhost:5000/record/1' result = Cv_latex(record)._get_url() assert expected == result
def test_get_publi_info_from_publication_info_a_list_of_two_elements(): publication_info_a_list_of_two_elements = Record({ 'publication_info': [{ 'journal_title': 'Int.J.Theor.Phys.', 'journal_volume': '38', 'page_start': '1113', 'page_end': '1133', 'year': 1999 }, { 'journal_title': 'Adv.Theor.Math.Phys.', 'journal_volume': '2', 'page_start': '231', 'page_end': '252', 'year': 1998 }] }) expected = [ 'Int.\\ J.\\ Theor.\\ Phys.\\ {\\bf 38}, 1113 (1999)', '[Adv.\\ Theor.\\ Math.\\ Phys.\\ {\\bf 2}, 231 (1998)]' ] result = Cv_latex( publication_info_a_list_of_two_elements)._get_publi_info() assert expected == result
def test_get_date_from_publication_info_uses_first_year_found(): publication_info = Record({'publication_info': [{}, {'year': '2012'}]}) expected = 2012 result = Cv_latex(publication_info)._get_date() assert expected == result
def test_get_date_from_thesis_uses_first_date_found(): thesis = Record({'thesis': {'date': '1966'}}) expected = 1966 result = Cv_latex(thesis)._get_date() assert expected == result
def test_get_publi_info_from_publication_info_an_empty_list(): publication_info_an_empty_list = Record({'publication_info': []}) expected = [] result = Cv_latex(publication_info_an_empty_list)._get_publi_info() assert expected == result
def test_get_date_from_imprints_uses_first_date_found(): imprints = Record({'imprints': [{}, {'date': '2011-03-29'}]}) expected = 'Mar 29, 2011' result = Cv_latex(imprints)._get_date() assert expected == result
def test_get_date_from_creation_modification_date_returns_none_when_no_creation_date( ): creation_modification_date_without_a_creation_date = Record( {'creation_modification_date': []}) assert Cv_latex( creation_modification_date_without_a_creation_date)._get_date() is None
def serialize(self, pid, record, links_factory=None): """Serialize a single cv_format_latex from a record. :param pid: Persistent identifier instance. :param record: Record instance. :param links_factory: Factory function for the link generation, which are added to the response. """ return Cv_latex(record).format()
def test_get_author_from_corporate_author_a_list_with_one_element(): corporate_author_a_list_of_one_element = Record( {'corporate_author': ['CMS Collaboration']}) expected = ['CMS Collaboration'] result = Cv_latex(corporate_author_a_list_of_one_element)._get_author() assert expected == result
def test_get_author_from_corporate_author_a_list_with_two_elements(): corporate_author_a_list_of_two_elements = Record( {'corporate_author': ['CMS Collaboration', 'The ATLAS Collaboration']}) expected = ['CMS Collaboration', 'The ATLAS Collaboration'] result = Cv_latex(corporate_author_a_list_of_two_elements)._get_author() assert expected == result
def test_get_date_from_legacy_creation_date(): legacy_creation_date = InspireRecord({ 'legacy_creation_date': '2012' }) expected = 2012 result = Cv_latex(legacy_creation_date)._get_date() assert expected == result
def test_get_author_from_authors_one_author_with_a_list_of_two_full_names(): one_author_with_a_list_of_two_full_names = Record( {'authors': [{ 'full_name': ['Englert, F.', 'Brout, R.'] }]}) expected = ['F.~B.~Englert, R.'] result = Cv_latex(one_author_with_a_list_of_two_full_names)._get_author() assert expected == result
def test_get_author_from_authors_one_author_with_a_list_of_one_full_name(): one_author_with_a_list_of_one_full_name = Record( {'authors': [{ 'full_name': ['Glashow, S.L.'] }]}) expected = ['S.~L.~Glashow'] result = Cv_latex(one_author_with_a_list_of_one_full_name)._get_author() assert expected == result
def test_get_author_from_authors_a_list_with_one_element(): authors_a_list_with_one_element = Record( {'authors': [{ 'full_name': 'Glashow, S.L.' }]}) expected = ['S.~L.~Glashow'] result = Cv_latex(authors_a_list_with_one_element)._get_author() assert expected == result
def test_get_date_from_creation_modification_date(): creation_modification_date = Record( {'creation_modification_date': [{ 'creation_date': '2012' }]}) expected = 2012 result = Cv_latex(creation_modification_date)._get_date() assert expected == result
def test_format_date_returns_none_when_datestruct_has_four_elements(): record = Record({}) cv_latex = Cv_latex(record) assert cv_latex._format_date((1993, 2, 2, 1)) is None
def test_parse_date_returns_none_when_datetext_is_none(): record = Record({}) cv_latex = Cv_latex(record) assert cv_latex.parse_date(None) is None
def test_parse_date_returns_none_when_datetext_is_an_empty_string(): record = Record({}) cv_latex = Cv_latex(record) assert cv_latex.parse_date('') is None
def test_parse_date_returns_none_when_datetext_is_not_of_type_str(): record = Record({}) cv_latex = Cv_latex(record) assert cv_latex.parse_date(0) is None