def test_query_doi_invalid_xml(self): """ Querying crossfer for a DOI number with invalid xml validated against schema """ doi = Brocker() query_doi = doi.query_doi(xml=datasample.invalid_query_xml) self.assertEqual(query_doi, None)
def test_query_doi_unparsed_xml(self): """ Querying crossfer for a DOI number with an unparsed xml """ doi = Brocker() self.assertRaises(XMLSyntaxError, lambda: doi.query_doi(xml=datasample.wrong_query_xml))
def test_query_doi_invalid_query_email(self): """ Testing the query_doi method using an invalid query e-mail """ doi = Brocker(query_email='*****@*****.**') self.assertRaises(HTTPError, lambda: doi.query_doi(xml=datasample.doc_without_doi))
def test_query_doi_invalid_api_url(self): """ Testing the query_doi method using an invalid URL """ doi = Brocker(query_email='http://wrongurl.crossref.org/servlet/query') self.assertRaises(URLError, lambda: doi.query_doi(xml=datasample.doc_without_doi))
def test_query_doi_true(self): """ Querying crossfer for a DOI number accoding to a document metadata that already have a DOI number registered """ doi = Brocker() query_doi = doi.query_doi(xml=datasample.doc_with_doi) self.assertEqual(query_doi, "10.1590/S2179-975X2012005000002")
def test_query_doi_false(self): """ Querying crossfer for a DOI number accoding to a document metadata that does not have a DOI number registed """ doi = Brocker() query_doi = doi.query_doi(xml=datasample.doc_without_doi) self.assertEqual(query_doi, None)