From 8e30ac7400d93c95c846c277813ffb30e39ed084 Mon Sep 17 00:00:00 2001 From: "Fabien C. Y. Benureau" Date: Tue, 14 Aug 2018 17:35:59 +0900 Subject: [PATCH] refix test + switch apis to https --- pubs/apis.py | 4 +- tests/mock_requests.py | 2 +- tests/test_apis_data.json | 86 +++++++++++++++++++-------------------- 3 files changed, 46 insertions(+), 46 deletions(-) diff --git a/pubs/apis.py b/pubs/apis.py index 78f9190..070d8fc 100644 --- a/pubs/apis.py +++ b/pubs/apis.py @@ -74,7 +74,7 @@ def _get_request(url, headers=None): def doi2bibtex(doi, **kwargs): """Return a bibtex string of metadata from a DOI""" - url = 'http://dx.doi.org/{}'.format(doi) + url = 'https://dx.doi.org/{}'.format(doi) headers = {'accept': 'application/x-bibtex'} r = _get_request(url, headers=headers) if r.encoding is None: @@ -89,7 +89,7 @@ def doi2bibtex(doi, **kwargs): def isbn2bibtex(isbn, **kwargs): """Return a bibtex string of metadata from an ISBN""" - url = 'http://www.ottobib.com/isbn/{}/bibtex'.format(isbn) + url = 'https://www.ottobib.com/isbn/{}/bibtex'.format(isbn) r = _get_request(url) soup = BeautifulSoup(r.text, "html.parser") citation = soup.find("textarea").text diff --git a/tests/mock_requests.py b/tests/mock_requests.py index a28f745..6660950 100644 --- a/tests/mock_requests.py +++ b/tests/mock_requests.py @@ -84,12 +84,12 @@ elif mode == 'COLLECT': except requests.exceptions.RequestException as e: error_msg = str(e) + text = intercept_text(text) _collected_responses.append((args, kwargs, text, status_code, error_msg)) _save_collected_responses() # yes, we save everytime, because it's not # clear how to run once after all the tests # have run. If you figure it out... - text = intercept_text(text) return MockingResponse(text, status_code, error_msg) def _save_collected_responses(): diff --git a/tests/test_apis_data.json b/tests/test_apis_data.json index 75fd757..8fe73aa 100644 --- a/tests/test_apis_data.json +++ b/tests/test_apis_data.json @@ -1,7 +1,7 @@ [ [ [ - "http://dx.doi.org/10.1007/BF01700692" + "https://dx.doi.org/10.1007/BF01700692" ], { "headers": { @@ -14,7 +14,7 @@ ], [ [ - "http://dx.doi.org/10.1007/BF01700692" + "https://dx.doi.org/10.1007/BF01700692" ], { "headers": { @@ -27,7 +27,7 @@ ], [ [ - "http://dx.doi.org/10.1086/307221" + "https://dx.doi.org/10.1086/307221" ], { "headers": { @@ -40,7 +40,7 @@ ], [ [ - "http://dx.doi.org/10.1086/307221" + "https://dx.doi.org/10.1086/307221" ], { "headers": { @@ -53,7 +53,7 @@ ], [ [ - "http://dx.doi.org/10.1103/INVALIDDOI.89.084044" + "https://dx.doi.org/10.1103/INVALIDDOI.89.084044" ], { "headers": { @@ -62,11 +62,11 @@ }, "\n\n\nError: DOI Not Found\n\n\n\n\n \n\n\n\n\n\n\n
\n\"Logo\"\n
\n\n
\n
\n
\n\n\n\n\n\n \n \n \n \n
\"\"\n HOME  | HANDBOOK  | FACTSHEETS  | FAQs  |  RESOURCES  | USERS  | NEWS  | MEMBERS AREA\n
\n\n\n
\n
\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n
\n\"\"\n
\n\n

DOI Not Found

\n\n
 
\n\n\n\n

10.1103/INVALIDDOI.89.084044

\n\n
 
\n\n\n\n\n

This DOI cannot be found in the DOI System. Possible reasons are:

\n\n\n
    \n\n
  • The DOI is incorrect in your source. Search for the item by name, title, or other metadata using a search engine.
  • \n\n
  • The DOI was copied incorrectly. Check to see that the string includes all the characters before and after the slash and no sentence punctuation marks.
  • \n\n
  • The DOI has not been activated yet. Please try again later, and report the problem if the error continues.
  • \n\n
\n\n\n\n
 
\n\n

You may report this error to the responsible DOI Registration Agency using the form below. Include your email address to receive confirmation and feedback.

\n\n
\n\n
\n\n\n\n\n\n\n\n\n\n\n\n\n
\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
Your Email Address:
Additional Information About the Error:
\n\n

\n\n
\n
\n\n\n\n\n
\"\"
\n\n
 
\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n
\nDOI System Proxy Server Documentation\n
\n\"DOI_disc_logo\"\n\n®, DOI®, DOI.ORG®, and shortDOI® are trademarks of the International DOI Foundation.\n
\n\n\n", 404, - "404 Client Error: for url: http://dx.doi.org/10.1103/INVALIDDOI.89.084044" + "404 Client Error: for url: https://dx.doi.org/10.1103/INVALIDDOI.89.084044" ], [ [ - "http://dx.doi.org/10.1186/s12984-017-0305-3" + "https://dx.doi.org/10.1186/s12984-017-0305-3" ], { "headers": { @@ -79,7 +79,7 @@ ], [ [ - "http://dx.doi.org/999999" + "https://dx.doi.org/999999" ], { "headers": { @@ -88,47 +88,14 @@ }, "\n\n\nError: DOI Not Found\n\n\n\n\n \n\n\n\n\n\n\n
\n\"Logo\"\n
\n\n
\n
\n
\n\n\n\n\n\n \n \n \n \n
\"\"\n HOME  | HANDBOOK  | FACTSHEETS  | FAQs  |  RESOURCES  | USERS  | NEWS  | MEMBERS AREA\n
\n\n\n
\n
\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n
\n\"\"\n
\n\n

DOI Not Found

\n\n
 
\n\n\n\n

10/999999

\n\n
 
\n\n\n\n\n

This DOI cannot be found in the DOI System. Possible reasons are:

\n\n\n
    \n\n
  • The DOI is incorrect in your source. Search for the item by name, title, or other metadata using a search engine.
  • \n\n
  • The DOI was copied incorrectly. Check to see that the string includes all the characters before and after the slash and no sentence punctuation marks.
  • \n\n
  • The DOI has not been activated yet. Please try again later, and report the problem if the error continues.
  • \n\n
\n\n\n\n
 
\n\n

You may report this error to the responsible DOI Registration Agency using the form below. Include your email address to receive confirmation and feedback.

\n\n
\n\n
\n\n\n\n\n\n\n\n\n\n\n\n\n
\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
Your Email Address:
Additional Information About the Error:
\n\n

\n\n
\n
\n\n\n\n\n
\"\"
\n\n
 
\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n
\nDOI System Proxy Server Documentation\n
\n\"DOI_disc_logo\"\n\n®, DOI®, DOI.ORG®, and shortDOI® are trademarks of the International DOI Foundation.\n
\n\n\n", 404, - "404 Client Error: for url: http://dx.doi.org/999999" - ], - [ - [ - "http://www.ottobib.com/isbn/9782081336742/bibtex" - ], - { - "headers": null - }, - "\n\n\n\n \n \n \n \n \n \n \n \n\n \n\n Bibliography and Works Cited Generator for MLA, APA, Wikipedia and Bibtex - OttoBib.com \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n
\n \n
\n
\n

OttoBib

\n

bibtex Format

\n
\n
\n\n
\n
\n \n
\n
\n
\n\n
\n

\n NOTE!\n
\n

    \n
  1. Verify accuracy of the data (particularly authors)
  2. \n
  3. Remember to do a HANGING INDENT (something I cannot do with HTML here)
  4. \n
  5. I strive for accuracy of the citations but you should treat this tool as a starting point in your works cited, because you still need to look it over.
  6. \n
\n

\n
\n
\n\n
\n \n\n \n", - 200, - null - ], - [ - [ - "http://www.ottobib.com/isbn/9782081336742/bibtex" - ], - { - "headers": null - }, - "\n\n\n\n \n \n \n \n \n \n \n \n\n \n\n Bibliography and Works Cited Generator for MLA, APA, Wikipedia and Bibtex - OttoBib.com \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n
\n \n
\n
\n

OttoBib

\n

bibtex Format

\n
\n
\n\n
\n
\n \n
\n
\n
\n\n
\n

\n NOTE!\n
\n

    \n
  1. Verify accuracy of the data (particularly authors)
  2. \n
  3. Remember to do a HANGING INDENT (something I cannot do with HTML here)
  4. \n
  5. I strive for accuracy of the citations but you should treat this tool as a starting point in your works cited, because you still need to look it over.
  6. \n
\n

\n
\n
\n\n
\n \n\n \n", - 200, - null - ], - [ - [ - "http://www.ottobib.com/isbn/9999999999999/bibtex" - ], - { - "headers": null - }, - "\n\n\n\n \n \n \n \n \n \n \n \n\n \n\n Bibliography and Works Cited Generator for MLA, APA, Wikipedia and Bibtex - OttoBib.com \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n
\n \n
\n\t

OttoBib

\n\t

Make a bibliography or works cited with just an ISBN. It's free, easy and FAST

\n\t

\n\t about ottobib and history\n\t \n\t

\n\t \n

\n\t
\n
\n\n
\n
\n\n
No Results for 9999999999999
\n
\n

\n Enter ISBN of book(s) - separate with commas (,)\n

\n \n read more about ISBN on Wikipedia\n \n
\n \n \n \n \n \n\n
\n \n
\n
\n\n
\n
\n\n

Did OttoBib help you? Then help us and Like us on Facebook!

\n
\n
\n\n\n
\n\n\n\n\n
\n \n\n \n", - 200, - null + "404 Client Error: for url: https://dx.doi.org/999999" ], [ [ "https://export.arxiv.org/api/query?id_list=1312.2021" ], {}, - "\n\n \n ArXiv Query: search_query=&id_list=1312.2021&start=0&max_results=10\n http://arxiv.org/api/eXBvi61X4ShcFWF7lwJgRo7KSFk\n 2018-08-14T00:00:00-04:00\n 1\n 0\n 10\n \n http://arxiv.org/abs/1312.2021v1\n 2013-12-06T21:33:40Z\n 2013-12-06T21:33:40Z\n Living with the Wrong Sign\n We describe a UV complete asymptotically fragile Lorentz-invariant theory\nexhibiting superluminal signal propagation. Its low energy effective action\ncontains \"wrong\" sign higher dimensional operators. Nevertheless, the theory\ngives rise to an S-matrix, which is defined at all energies. As expected for a\nnon-local theory, the corresponding scattering amplitudes are not exponentially\nbounded on the physical sheet, but otherwise are healthy. We study some of the\nphysical consequences of this S-matrix.\n\n \n Patrick Cooper\n \n \n Sergei Dubovsky\n \n \n Ali Mohsen\n \n 10.1103/PhysRevD.89.084044\n \n Phys. Rev. D 89, 084044 (2014)\n \n \n \n \n \n \n\n", + "\n\n \n ArXiv Query: search_query=&id_list=1312.2021&start=0&max_results=10\n http://arxiv.org/api/eXBvi61X4ShcFWF7lwJgRo7KSFk\n 2018-08-14T00:00:00-04:00\n 1\n 0\n 10\n \n http://arxiv.org/abs/1312.2021v1\n 2013-12-06T21:33:40Z\n 2013-12-06T21:33:40Z\n Living with the Wrong Sign\n We describe a UV complete asymptotically fragile Lorentz-invariant theory\nexhibiting superluminal signal propagation. Its low energy effective action\ncontains \"wrong\" sign higher dimensional operators. Nevertheless, the theory\ngives rise to an S-matrix, which is defined at all energies. As expected for a\nnon-local theory, the corresponding scattering amplitudes are not exponentially\nbounded on the physical sheet, but otherwise are healthy. We study some of the\nphysical consequences of this S-matrix.\n\n \n Patrick Cooper\n \n \n Sergei Dubovsky\n \n \n Ali Mohsen\n \n 10.1103/INVALIDDOI.89.084044\n \n Phys. Rev. D 89, 084044 (2014)\n \n \n \n \n \n \n\n", 200, null ], @@ -185,5 +152,38 @@ "\n\n \n ArXiv Query: search_query=&id_list=math/0211159&start=0&max_results=10\n http://arxiv.org/api/4nVRTcAL5Np4oaGFQnqVPG0+c5k\n 2018-08-14T00:00:00-04:00\n 1\n 0\n 10\n \n http://arxiv.org/abs/math/0211159v1\n 2002-11-11T16:11:49Z\n 2002-11-11T16:11:49Z\n The entropy formula for the Ricci flow and its geometric applications\n We present a monotonic expression for the Ricci flow, valid in all dimensions\nand without curvature assumptions. It is interpreted as an entropy for a\ncertain canonical ensemble. Several geometric applications are given. In\nparticular, (1) Ricci flow, considered on the space of riemannian metrics\nmodulo diffeomorphism and scaling, has no nontrivial periodic orbits (that is,\nother than fixed points); (2) In a region, where singularity is forming in\nfinite time, the injectivity radius is controlled by the curvature; (3) Ricci\nflow can not quickly turn an almost euclidean region into a very curved one, no\nmatter what happens far away. We also verify several assertions related to\nRichard Hamilton's program for the proof of Thurston geometrization conjecture\nfor closed three-manifolds, and give a sketch of an eclectic proof of this\nconjecture, making use of earlier results on collapsing with local lower\ncurvature bound.\n\n \n Grisha Perelman\n \n 39 pages\n \n \n \n \n \n \n\n", 200, null + ], + [ + [ + "https://www.ottobib.com/isbn/9782081336742/bibtex" + ], + { + "headers": null + }, + "\n\n\n\n \n \n \n \n \n \n \n \n\n \n\n Bibliography and Works Cited Generator for MLA, APA, Wikipedia and Bibtex - OttoBib.com \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n
\n \n
\n
\n

OttoBib

\n

bibtex Format

\n
\n
\n\n
\n
\n \n
\n
\n
\n\n
\n

\n NOTE!\n
\n

    \n
  1. Verify accuracy of the data (particularly authors)
  2. \n
  3. Remember to do a HANGING INDENT (something I cannot do with HTML here)
  4. \n
  5. I strive for accuracy of the citations but you should treat this tool as a starting point in your works cited, because you still need to look it over.
  6. \n
\n

\n
\n
\n\n
\n \n\n \n", + 200, + null + ], + [ + [ + "https://www.ottobib.com/isbn/9782081336742/bibtex" + ], + { + "headers": null + }, + "\n\n\n\n \n \n \n \n \n \n \n \n\n \n\n Bibliography and Works Cited Generator for MLA, APA, Wikipedia and Bibtex - OttoBib.com \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n
\n \n
\n
\n

OttoBib

\n

bibtex Format

\n
\n
\n\n
\n
\n \n
\n
\n
\n\n
\n

\n NOTE!\n
\n

    \n
  1. Verify accuracy of the data (particularly authors)
  2. \n
  3. Remember to do a HANGING INDENT (something I cannot do with HTML here)
  4. \n
  5. I strive for accuracy of the citations but you should treat this tool as a starting point in your works cited, because you still need to look it over.
  6. \n
\n

\n
\n
\n\n
\n \n\n \n", + 200, + null + ], + [ + [ + "https://www.ottobib.com/isbn/9999999999999/bibtex" + ], + { + "headers": null + }, + "\n\n\n\n \n \n \n \n \n \n \n \n\n \n\n Bibliography and Works Cited Generator for MLA, APA, Wikipedia and Bibtex - OttoBib.com \n \n \n\n \n \n \n \n \n \n \n \n \n \n \n
\n \n
\n\t

OttoBib

\n\t

Make a bibliography or works cited with just an ISBN. It's free, easy and FAST

\n\t

\n\t about ottobib and history\n\t \n\t

\n\t \n

\n\t
\n
\n\n
\n
\n\n
No Results for 9999999999999
\n
\n

\n Enter ISBN of book(s) - separate with commas (,)\n

\n \n read more about ISBN on Wikipedia\n \n
\n \n \n \n \n \n\n
\n \n
\n
\n\n
\n
\n\n

Did OttoBib help you? Then help us and Like us on Facebook!

\n
\n
\n\n\n
\n\n\n\n\n
\n \n\n \n", + 200, + null ] ] \ No newline at end of file