-class TestFetch(unittest.TestCase):
- def setUp(self) -> None:
- web_server = HTTPServer(('', 0), FakeGlowficHTTPRequestHandler)
- self._port = web_server.socket.getsockname()[1]
- self._thread = threading.Thread(target=web_server.serve_forever)
- self._thread.start()
- self._stop_server = web_server.shutdown
-
- def tearDown(self) -> None:
- self._stop_server()
- self._thread.join()
-
- def testFetch(self) -> None:
- paperdoorknob.fetch(f"http://localhost:{self._port}", TIMEOUT)
-
- def testFetchErrors(self) -> None:
- with self.assertRaises(requests.HTTPError):
- paperdoorknob.fetch(
- f"http://localhost:{self._port}/not_found", TIMEOUT)
- with self.assertRaises(requests.HTTPError):
- paperdoorknob.fetch(
- f"http://localhost:{self._port}/server_error", TIMEOUT)
+ def testPDF(self) -> None:
+ with DirectFetcher(TIMEOUT) as f:
+ with open("test.tex", 'wb') as out:
+ spec = Spec(
+ f"http://localhost:{self._port}",
+ f,
+ PandocTexifier('pandoc'),
+ out)
+ paperdoorknob.process(spec)
+ subprocess.run(['pdflatex', 'test.tex'],
+ stdin=subprocess.DEVNULL, check=True)