X-Git-Url: http://git.scottworley.com/paperdoorknob/blobdiff_plain/19ed28f37b59e480cebe8f122e07ce18ce536db8..d6e27f4bb8ab56ca2545a72ab3433a12b1eb4a7f:/glowfic_test.py?ds=inline diff --git a/glowfic_test.py b/glowfic_test.py index 52d6f86..befd0b5 100644 --- a/glowfic_test.py +++ b/glowfic_test.py @@ -4,10 +4,12 @@ # under the terms of the GNU General Public License as published by the # Free Software Foundation, version 3. - +from io import BytesIO from sys import stderr import unittest +from typing import Optional + from fetch import FakeFetcher from images import FakeImageStore from glowfic import makeChunk, Thread @@ -15,9 +17,10 @@ from spec import Spec from texify import PandocTexifier -def spec_for_testing(html: bytes) -> Spec: - return Spec('test', - FakeFetcher({'test?view=flat': html}), +def spec_for_testing(html: bytes, outbuf: Optional[BytesIO] = None) -> Spec: + return Spec('https://fake/test', + FakeFetcher({'https://fake/test': html, + 'https://fake/test?view=flat': html}), FakeImageStore(), lambda x: x, lambda x: None, @@ -26,7 +29,7 @@ def spec_for_testing(html: bytes) -> Spec: 20, b'', None, - stderr.buffer, + stderr.buffer if outbuf is None else outbuf, lambda x: None) @@ -87,6 +90,21 @@ class TestMakeChunk(unittest.TestCase): self.assertEqual( PandocTexifier("pandoc").texify(c.character), b'{Keltham}\n') + def testMinimal(self) -> None: + t = Thread(spec_for_testing(b''' +
+