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 }] }) cv_latex_html_text = Cv_latex_html_text( publication_info_a_list_of_two_elements, 'cv_latex_html_text', ',') expected = [ 'Int.J.Theor.Phys. 38 (1999) 1113-1133', 'Adv.Theor.Math.Phys. 2 (1998) 231-252' ] result = cv_latex_html_text._get_publi_info() assert expected == result
def serialize(self, pid, record, links_factory=None): """Serialize a single cv_format_html 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_html_text(record, 'cv_latex_html', '<br/>').format()
def test_get_title_when_titles_is_not_a_list_without_subtitles(): titles_not_a_list_without_subtitles = Record({'titles': {'title': 'foo'}}) cv_latex_html_text = Cv_latex_html_text( titles_not_a_list_without_subtitles, 'cv_latex_html_text', ',') expected = 'foo' result = cv_latex_html_text._get_title() assert expected == result
def test_get_title_capitalizes_when_title_is_uppercase(): title_is_uppercase = Record({'titles': [{'title': 'FOO'}]}) cv_latex_html_text = Cv_latex_html_text(title_is_uppercase, 'cv_latex_html_text', ',') expected = 'Foo' result = cv_latex_html_text._get_title() assert expected == result
def test_get_title_capitalizes_when_title_contains_uppercase_the(): title_contains_uppercase_the = {'titles': [{'title': 'foo THE bar'}]} cv_latex_html_text = Cv_latex_html_text(title_contains_uppercase_the, 'cv_latex_html_text', ',') expected = 'Foo The Bar' result = cv_latex_html_text._get_title() assert expected == result
def test_get_author_from_corporate_author_an_empty_list(): corporate_author_an_empty_list = Record({'corporate_author': []}) cv_latex_html_text = Cv_latex_html_text(corporate_author_an_empty_list, 'cv_latex_html_text', ',') expected = [] result = cv_latex_html_text._get_author() assert expected == result
def test_get_title_returns_empty_string_when_titles_is_an_empty_list(): titles_an_empty_list = Record({'titles': []}) cv_latex_html_text = Cv_latex_html_text(titles_an_empty_list, 'cv_latex_html_text', ',') expected = '' result = cv_latex_html_text._get_title() assert expected == result
def test_get_title_returns_empty_string_when_no_titles(): no_titles = Record({}) cv_latex_html_text = Cv_latex_html_text(no_titles, 'cv_latex_html_text', ',') expected = '' result = cv_latex_html_text._get_title() assert expected == result
def test_get_publi_info_from_publication_info_an_empty_list(): publication_info_an_empty_list = Record({'publication_info': []}) cv_latex_html_text = Cv_latex_html_text(publication_info_an_empty_list, 'cv_latex_html_text', ',') expected = [] result = cv_latex_html_text._get_publi_info() 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']}) cv_latex_html_text = Cv_latex_html_text( corporate_author_a_list_of_two_elements, 'cv_latex_html_text', ',') expected = ['CMS Collaboration', 'The ATLAS Collaboration'] result = cv_latex_html_text._get_author() assert expected == result
def test_format_cv_latex_html(app): record = get_db_record('literature', 4328) expected = ( '<a href="localhost:5000/record/4328">Partial Symmetries of Weak Interactions.' '</a>,By S.L. Glashow.,<a href="http://dx.doi.org/10.1016/0029-5582(61)90469-2"' '>10.1016/0029-5582(61)90469-2</a>.,Nucl.Phys. 22 (1961) 579-588.,,') result = Cv_latex_html_text(record, 'cv_latex_html', ',').format() assert expected == result
def test_get_author_from_corporate_author_a_list_with_one_element(): corporate_author_a_list_of_one_element = InspireRecord( {'corporate_author': ['CMS Collaboration']}) cv_latex_html_text = Cv_latex_html_text( corporate_author_a_list_of_one_element, 'cv_latex_html_text', ',') expected = ['CMS Collaboration'] result = cv_latex_html_text._get_author() assert expected == result
def test_get_author_from_authors_one_author_with_an_empty_list_of_full_names(): one_author_with_an_empty_list_of_full_names = Record( {'authors': [{ 'full_name': [] }]}) cv_latex_html_text = Cv_latex_html_text( one_author_with_an_empty_list_of_full_names, 'cv_latex_html', ',') expected = [] result = cv_latex_html_text._get_author() 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.'] }]}) cv_latex_html_text = Cv_latex_html_text( one_author_with_a_list_of_two_full_names, 'cv_latex_html', ',') expected = ['F.Brout Englert, R.'] result = cv_latex_html_text._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.'] }]}) cv_latex_html_text = Cv_latex_html_text( one_author_with_a_list_of_one_full_name, 'cv_latex_html', ',') expected = ['S.L. Glashow'] result = cv_latex_html_text._get_author() assert expected == result
def test_get_publi_info_from_publication_info_with_journal_title(): journal_title = Record( {'publication_info': [{ 'journal_title': 'Nucl.Phys.' }]}) cv_latex_html_text = Cv_latex_html_text(journal_title, 'cv_latex_html_text', ',') expected = ['Submitted to: Nucl.Phys.'] result = cv_latex_html_text._get_publi_info() 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.' }]}) cv_latex_html_text = Cv_latex_html_text(authors_a_list_with_one_element, 'cv_latex_html', ',') expected = ['S.L. Glashow'] result = cv_latex_html_text._get_author() assert expected == result
def test_get_title_when_titles_is_a_list_of_one_element_with_subtitle(): titles_a_list_of_one_element_with_subtitle = Record( {'titles': [{ 'title': 'foo', 'subtitle': 'bar' }]}) cv_latex_html_text = Cv_latex_html_text( titles_a_list_of_one_element_with_subtitle, 'cv_latex_html_text', ',') expected = 'foo : bar' result = cv_latex_html_text._get_title() assert expected == result
def test_get_title_when_titles_is_a_list_of_one_element_without_subtitles(): titles_a_list_of_one_element_without_subtitles = InspireRecord( {'titles': [{ 'title': 'foo' }]}) cv_latex_html_text = Cv_latex_html_text( titles_a_list_of_one_element_without_subtitles, 'cv_latex_html_text', ',') expected = 'foo' result = cv_latex_html_text._get_title() assert expected == result
def test_get_publi_info_from_publication_info_with_page_artid_not_a_list(): page_artid_not_a_list = Record( {'publication_info': [{ 'journal_title': 'JHEP', 'page_artid': '190' }]}) cv_latex_html_text = Cv_latex_html_text(page_artid_not_a_list, 'cv_latex_html_text', ',') expected = ['JHEP 190'] result = cv_latex_html_text._get_publi_info() assert expected == result
def test_get_publi_info_from_publication_info_with_journal_title_an_empty_list( ): journal_title_an_empty_list = Record( {'publication_info': [{ 'journal_title': [] }]}) cv_latex_html_text = Cv_latex_html_text(journal_title_an_empty_list, 'cv_latex_html_text', ',') expected = [] result = cv_latex_html_text._get_publi_info() assert expected == result
def test_get_publi_info_from_publication_info_with_page_start(): page_start = Record( {'publication_info': [{ 'journal_title': 'JHEP', 'page_start': '190' }]}) cv_latex_html_text = Cv_latex_html_text(page_start, 'cv_latex_html_text', ',') expected = ['Submitted to: JHEP'] result = cv_latex_html_text._get_publi_info() assert expected == result
def test_get_title_when_titles_is_not_a_list_with_subtitle(): titles_not_a_list_with_subtitle = InspireRecord( {'titles': { 'title': 'foo', 'subtitle': 'bar' }}) cv_latex_html_text = Cv_latex_html_text(titles_not_a_list_with_subtitle, 'cv_latex_html_text', ',') expected = 'foo : bar' result = cv_latex_html_text._get_title() assert expected == result
def test_get_publi_info_from_publication_info_with_year_an_empty_list(): year_an_empty_list = Record( {'publication_info': [{ 'journal_title': 'Phys.Rev.', 'year': [] }]}) cv_latex_html_text = Cv_latex_html_text(year_an_empty_list, 'cv_latex_html_text', ',') expected = ['Submitted to:Phys.Rev.'] result = cv_latex_html_text._get_publi_info() assert expected == result
def test_get_publi_info_from_publication_info_with_journal_title_a_list_of_two_elements( ): journal_title_a_list_of_two_elements = Record( {'publication_info': [{ 'journal_title': ['foo', 'bar'] }]}) cv_latex_html_text = Cv_latex_html_text( journal_title_a_list_of_two_elements, 'cv_latex_html_text', ',') expected = ['Submitted to:bar'] result = cv_latex_html_text._get_publi_info() assert expected == result
def serialize_search(self, pid_fetcher, search_result, links=None, item_links_factory=None): """Serialize a search result. :param pid_fetcher: Persistent identifier fetcher. :param search_result: Elasticsearch search result. :param links: Dictionary of links to add to response. """ records = [] for hit in search_result['hits']['hits']: records.append(Cv_latex_html_text(hit['_source'], 'cv_latex_html', '<br/>').format()) return "\n".join(records)
def test_get_publi_info_from_publication_info_with_journal_volume(): journal_volume = Record({ 'publication_info': [{ 'journal_title': 'eConf', 'journal_volume': 'C050318' }] }) cv_latex_html_text = Cv_latex_html_text(journal_volume, 'cv_latex_html_text', ',') expected = ['eConf C050318'] result = cv_latex_html_text._get_publi_info() assert expected == result
def test_get_publi_info_from_publication_info_with_year(): year_not_a_list = Record({ 'publication_info': [{ 'journal_title': 'Phys.Lett.', 'year': '1999' }] }) cv_latex_html_text = Cv_latex_html_text(year_not_a_list, 'cv_latex_html_text', ',') expected = ['Submitted to: Phys.Lett. (1999)'] result = cv_latex_html_text._get_publi_info() assert expected == result
def test_get_publi_info_from_publication_info_with_journal_issue(): journal_issue = Record({ 'publication_info': [{ 'journal_title': 'Class.Quant.Grav.', 'journal_issue': '10' }] }) cv_latex_html_text = Cv_latex_html_text(journal_issue, 'cv_latex_html_text', ',') expected = ['Submitted to: Class.Quant.Grav.'] result = cv_latex_html_text._get_publi_info() assert expected == result
def test_get_publi_info_from_pubinfo_freetext(): pubinfo_freetext = Record({ 'publication_info': [{ 'pubinfo_freetext': 'Phys. Lett. 12 (1964) 132-133' }] }) cv_latex_html_text = Cv_latex_html_text(pubinfo_freetext, 'cv_latex_html_text', ',') expected = 'Phys. Lett. 12 (1964) 132-133' result = cv_latex_html_text._get_publi_info() assert expected == result