def test_getting_of_orcids_from_xml_document(self, _, xml_basename,
                                              expected_orcids):
     _get_orcids = add_orcid._get_orcids
     with mock_open(xml_basename,
                    'r') as xml_file:  # TODO: Rename to xml_open
         xml_data = parse(xml_file)
         orcids = _get_orcids(xml_data)
         self.assertEquals(orcids, expected_orcids)
 def test_getting_arxiv_id_from_inspire(self, _, doi, arxiv_id, expected_exception):
     _get_arxiv_id_from_inspire = arxiv_category._get_arxiv_id_from_inspire
     with patch("invenio.modules.checker.checkerext.plugins.scoap3_arxiv_category.urllib.urlopen") as mock_urlopen:
         if expected_exception:
             mock_urlopen.side_effect = expected_exception
             self.assertRaises(expected_exception, _get_arxiv_id_from_inspire, doi)
         else:
             mock_urlopen.return_value = mock_open(doi, "r")
             self.assertEqual(_get_arxiv_id_from_inspire(doi), arxiv_id)
 def test_finding_arxiv_categories_from_arxiv_org(self, _, arxiv_id, expected_categories, expected_exception):
     _get_arxiv_categories_from_arxiv_org = arxiv_category._get_arxiv_categories_from_arxiv_org
     with patch("invenio.modules.checker.checkerext.plugins.scoap3_arxiv_category.urllib.urlopen") as mock_urlopen:
         if expected_exception:
             mock_urlopen.side_effect = expected_exception()
             self.assertRaises(expected_exception, _get_arxiv_categories_from_arxiv_org, arxiv_id)
         else:
             mock_urlopen.return_value = mock_open(arxiv_id, "r")
             self.assertEqual(_get_arxiv_categories_from_arxiv_org(arxiv_id), expected_categories)
示例#4
0
 def test_getting_arxiv_id_from_inspire(self, _, doi, arxiv_id, expected_exception):
     _get_arxiv_id_from_inspire = arxiv_category._get_arxiv_id_from_inspire
     with patch('invenio.modules.checker.checkerext.checks.scoap3_arxiv_category.urllib.urlopen') as mock_urlopen:
         if expected_exception:
             mock_urlopen.side_effect = expected_exception
             self.assertRaises(expected_exception,
                             _get_arxiv_id_from_inspire, doi)
         else:
             mock_urlopen.return_value = mock_open(doi, 'r')
             self.assertEqual(_get_arxiv_id_from_inspire(doi),
                             arxiv_id)
示例#5
0
 def test_finding_arxiv_categories_from_arxiv_org(self, _, arxiv_id, expected_categories, expected_exception):
     _get_arxiv_categories_from_arxiv_org = arxiv_category._get_arxiv_categories_from_arxiv_org
     with patch('invenio.modules.checker.checkerext.checks.scoap3_arxiv_category.urllib.urlopen') as mock_urlopen:
         if expected_exception:
             mock_urlopen.side_effect = expected_exception()
             self.assertRaises(expected_exception,
                                 _get_arxiv_categories_from_arxiv_org, arxiv_id)
         else:
             mock_urlopen.return_value = mock_open(arxiv_id, 'r')
             self.assertEqual(_get_arxiv_categories_from_arxiv_org(arxiv_id),
                                 expected_categories)
 def test_getting_of_orcids_from_xml_document(self, _, xml_basename, expected_orcids):
     _get_orcids = add_orcid._get_orcids
     with mock_open(xml_basename, 'r') as xml_file:  # TODO: Rename to xml_open
         xml_data = parse(xml_file)
         orcids = _get_orcids(xml_data)
         self.assertEquals(orcids, expected_orcids)