]> git.scottworley.com Git - paperdoorknob/blobdiff - paperdoorknob_test.py
Extensible, flag-controlled DOM filters
[paperdoorknob] / paperdoorknob_test.py
index 425d5e3f21c6c8cb827ba8694dae0a7435608f89..aa50340ecfd7709ed3437b9ce006d22a5fe1804d 100644 (file)
@@ -13,6 +13,7 @@ import subprocess
 import paperdoorknob
 
 from testing.fakeserver import FakeGlowficServer
+from domfilter import ApplyDOMFilters
 from fetch import DirectFetcher, FakeFetcher, Fetcher
 from spec import Spec
 from texify import DirectTexifier, PandocTexifier, VerifyingTexifier
@@ -31,11 +32,10 @@ class BaseTestProcess(ABC):
         raise NotImplementedError()
 
     def testReplies(self) -> None:
-        replies = paperdoorknob.replies(
-            paperdoorknob.clean(
-                paperdoorknob.parse(
-                    self.fetcher().fetch(
-                        self.url()))))
+        replies = list(paperdoorknob.replies(
+            paperdoorknob.parse(self.fetcher().fetch(self.url()))))
+        for r in replies:
+            ApplyDOMFilters('NoEdit,NoFooter', r)
         assert [r.text.strip() for r in replies] == [
             "This is glowfic",
             "You sure?",
@@ -46,6 +46,8 @@ class BaseTestProcess(ABC):
         spec = Spec(
             self.url(),
             self.fetcher(),
+            lambda x: x,
+            lambda x: ApplyDOMFilters('NoEdit,NoFooter', x),
             PandocTexifier('pandoc'),
             buf)
         paperdoorknob.process(spec)
@@ -61,7 +63,13 @@ Pretty sure.
         texifier = VerifyingTexifier(
             PandocTexifier('pandoc'), DirectTexifier())
         buf = io.BytesIO()
-        spec = Spec(self.url(), self.fetcher(), texifier, buf)
+        spec = Spec(
+            self.url(),
+            self.fetcher(),
+            lambda x: x,
+            lambda x: ApplyDOMFilters('NoEdit,NoFooter', x),
+            texifier,
+            buf)
         paperdoorknob.process(spec)
 
     def testPDF(self) -> None:
@@ -69,6 +77,8 @@ Pretty sure.
             spec = Spec(
                 self.url(),
                 self.fetcher(),
+                lambda x: x,
+                lambda x: ApplyDOMFilters('NoEdit,NoFooter', x),
                 PandocTexifier('pandoc'),
                 out)
             paperdoorknob.process(spec)