# Path: pubs/p3.py
#     def input():
#     def _get_raw_stdout():
#     def _get_raw_stderr():
#     def u_maybe(s):
#         def __init__(self, *args, **kwargs):
#         def write(self, s):
#     def _get_fake_stdio_ucontent(stdio):
#         def _print_message(self, message, file=None):
#     def _get_raw_stdout():
#     def _get_raw_stderr():
#     def u_maybe(s):
#         def __init__(self, *args, **kwargs):
#         def write(self, s):
#     def _fake_stdio(additional_out=False):
#     def _get_fake_stdio_ucontent(stdio):
# def isbasestr(obj):
#     class StdIO(io.BytesIO):
#     class ArgumentParser(argparse.ArgumentParser):
#     class StdIO(io.BytesIO):
# 
# Path: pubs/apis.py
# class ReferenceNotFoundError(Exception):
# def get_bibentry_from_api(id_str, id_type, try_doi=True, ui=None, raw=False):
# def _get_request(url, headers=None):
# def doi2bibtex(doi, **kwargs):
# def isbn2bibtex(isbn, **kwargs):
# def _is_arxiv_oldstyle(arxiv_id):
# def _extract_arxiv_id(entry):
# def arxiv2bibtex(arxiv_id, try_doi=True, ui=None):
# 
# Path: pubs/apis.py
# def _is_arxiv_oldstyle(arxiv_id):
#     return re.match(r"(arxiv\:)?[a-z\-]+\/[0-9]+(v[0-9]+)?", arxiv_id.lower()) is not None
# 
# def _extract_arxiv_id(entry):
#     pattern = r"http[s]?://arxiv.org/abs/(?P<entry_id>.+)"
#     return re.search(pattern, entry['id']).groupdict()['entry_id']


import unittest
import mock
import dotdot
import mock_requests
from pubs.p3 import ustr
from pubs import apis
from pubs.apis import _is_arxiv_oldstyle, _extract_arxiv_id
from __future__ import unicode_literals







class APITests(unittest.TestCase):

    @mock.patch('pubs.apis.requests.get', side_effect=mock_requests.mock_requests_get)
    def test_readme(self, reqget):
        apis.doi2bibtex('10.1007/s00422-012-0514-6')
        apis.isbn2bibtex('978-0822324669')
        apis.arxiv2bibtex('math/9501234')

class TestDOI2Bibtex(APITests):

    @mock.patch('pubs.apis.requests.get', side_effect=mock_requests.mock_requests_get)
    def test_unicode(self, reqget):
        bib = apis.doi2bibtex('10.1007/BF01700692')
        self.assertIsInstance(bib, ustr)
        self.assertIn('Kurt Gödel', bib)

    @mock.patch('pubs.apis.requests.get', side_effect=mock_requests.mock_requests_get)
    def test_parses_to_bibtex(self, reqget):
        bib = apis.get_bibentry_from_api('10.1007/BF01700692', 'DOI')
        self.assertEqual(len(bib), 1)
        entry = bib[list(bib)[0]]
        self.assertEqual(entry['author'][0], 'Gödel, Kurt')

# Path: pubs/p3.py
#     def input():
#     def _get_raw_stdout():
#     def _get_raw_stderr():
#     def u_maybe(s):
#         def __init__(self, *args, **kwargs):
#         def write(self, s):
#     def _get_fake_stdio_ucontent(stdio):
#         def _print_message(self, message, file=None):
#     def _get_raw_stdout():
#     def _get_raw_stderr():
#     def u_maybe(s):
#         def __init__(self, *args, **kwargs):
#         def write(self, s):
#     def _fake_stdio(additional_out=False):
#     def _get_fake_stdio_ucontent(stdio):
# def isbasestr(obj):
#     class StdIO(io.BytesIO):
#     class ArgumentParser(argparse.ArgumentParser):
#     class StdIO(io.BytesIO):
# 
# Path: pubs/apis.py
# class ReferenceNotFoundError(Exception):
# def get_bibentry_from_api(id_str, id_type, try_doi=True, ui=None, raw=False):
# def _get_request(url, headers=None):
# def doi2bibtex(doi, **kwargs):
# def isbn2bibtex(isbn, **kwargs):
# def _is_arxiv_oldstyle(arxiv_id):
# def _extract_arxiv_id(entry):
# def arxiv2bibtex(arxiv_id, try_doi=True, ui=None):
# 
# Path: pubs/apis.py
# def _is_arxiv_oldstyle(arxiv_id):
#     return re.match(r"(arxiv\:)?[a-z\-]+\/[0-9]+(v[0-9]+)?", arxiv_id.lower()) is not None
# 
# def _extract_arxiv_id(entry):
#     pattern = r"http[s]?://arxiv.org/abs/(?P<entry_id>.+)"
#     return re.search(pattern, entry['id']).groupdict()['entry_id']


# Path: tests/test_apis.py
import unittest
import mock
import dotdot
import mock_requests
from pubs.p3 import ustr
from pubs import apis
from pubs.apis import _is_arxiv_oldstyle, _extract_arxiv_id

from __future__ import unicode_literals







class APITests(unittest.TestCase):

    @mock.patch('pubs.apis.requests.get', side_effect=mock_requests.mock_requests_get)
    def test_readme(self, reqget):
        apis.doi2bibtex('10.1007/s00422-012-0514-6')
        apis.isbn2bibtex('978-0822324669')
        apis.arxiv2bibtex('math/9501234')

class TestDOI2Bibtex(APITests):

    @mock.patch('pubs.apis.requests.get', side_effect=mock_requests.mock_requests_get)
    def test_unicode(self, reqget):
        bib = apis.doi2bibtex('10.1007/BF01700692')
        self.assertIsInstance(bib, ustr)
        self.assertIn('Kurt Gödel', bib)

    @mock.patch('pubs.apis.requests.get', side_effect=mock_requests.mock_requests_get)
    def test_parses_to_bibtex(self, reqget):
        bib = apis.get_bibentry_from_api('10.1007/BF01700692', 'DOI')
        self.assertEqual(len(bib), 1)
        entry = bib[list(bib)[0]]
        self.assertEqual(entry['author'][0], 'Gödel, Kurt')

        self.assertEqual(entry['title'],