Ejemplo n.º 1
0
 def test_extraction_of_countries_from_affilation(self, _, unstructured_affiliations, expected_countries):
     extract_countries = nations.extract_countries
     if is_exception_of(expected_countries, Exception):
         self.assertRaises(expected_countries,
                           extract_countries, unstructured_affiliations)
     else:
         countries = extract_countries(unstructured_affiliations)
         self.assertEquals(countries, expected_countries)
Ejemplo n.º 2
0
 def test_setting_of_countries_of_affilation_to_author(self, _, record, expected_result):
     check_record = nations.check_record
     if is_exception_of(expected_result, KeyError):
         self.assertRaises(expected_result,
                           check_record, record)
     else:
         resulting_record = check_record(record)
         for idx_author, author in enumerate(resulting_record['authors']):
             expected_author_affiliations = expected_result[idx_author]
             self.assertItemsEqual(author['affiliations'], expected_author_affiliations)
Ejemplo n.º 3
0
 def test_extraction_of_countries_from_affilation(self, _,
                                                  unstructured_affiliations,
                                                  expected_countries):
     extract_countries = nations.extract_countries
     if is_exception_of(expected_countries, Exception):
         self.assertRaises(expected_countries, extract_countries,
                           unstructured_affiliations)
     else:
         countries = extract_countries(unstructured_affiliations)
         self.assertEquals(countries, expected_countries)
Ejemplo n.º 4
0
 def test_setting_of_countries_of_affilation_to_author(
         self, _, record, expected_result):
     check_record = nations.check_record
     if is_exception_of(expected_result, KeyError):
         self.assertRaises(expected_result, check_record, record)
     else:
         resulting_record = check_record(record)
         for idx_author, author in enumerate(resulting_record['authors']):
             expected_author_affiliations = expected_result[idx_author]
             self.assertItemsEqual(author['affiliations'],
                                   expected_author_affiliations)
 def test_getting_inspireid_from_database(self, _, doi, expected_recid):
     from invenio.modules.checker.checkerext.checks.scoap3_add_inspire_id import get_inspireid_from_database
     with patch('invenio.ext.sqlalchemy.db', mock_db([expected_recid])) as mocked_db:
         if is_exception_of(expected_recid, Exception):  # TODO: Split expected_exception
             self.assertRaises(expected_recid,
                               get_inspireid_from_database, doi)
         else:
             returned_recid = get_inspireid_from_database(doi)
             self.assertEquals(returned_recid, expected_recid)
             self.assertTrue(mocked_db.session.query.filter.called or mocked_db.session.filter.called)
             self.assertTrue(mocked_db.session.query.filter.all.called or mocked_db.session.query.filter.one.called)