]> git.scottworley.com Git - paperdoorknob/blobdiff - glowfic_test.py
Move per-thread processing stuff into Thread
[paperdoorknob] / glowfic_test.py
index 52d6f86cb9a1681ccaf4d34e3784d054e5352ed5..bd26e3c9dfc5bc0ee4ec02eead21e34bdca42689 100644 (file)
@@ -16,8 +16,9 @@ from texify import PandocTexifier
 
 
 def spec_for_testing(html: bytes) -> Spec:
-    return Spec('test',
-                FakeFetcher({'test?view=flat': html}),
+    return Spec('https://fake/test',
+                FakeFetcher({'https://fake/test': html,
+                             'https://fake/test?view=flat': html}),
                 FakeImageStore(),
                 lambda x: x,
                 lambda x: None,
@@ -102,6 +103,30 @@ class TestThread(unittest.TestCase):
             </body></html>'''))
         self.assertEqual(t.title(), 'Teh Story!')
 
+    def testNextThreadRelative(self) -> None:
+        t = Thread(spec_for_testing(b'''
+            <html><body>
+              <div class="post-navheader">
+                <a class="view-button-link" href="/posts/4567"><div class="view-button">Next Post &raquo;</div>
+                </a><a class="view-button-link" href="/posts/4321"><div class="view-button float-none">&laquo; Previous Post</div>
+                </a>
+              </div>
+              <div class="post-container post-post">The "post"</div>
+            </body></html>'''))
+        self.assertEqual(t.next_thread(), 'https://fake/posts/4567')
+
+    def testNextThreadAbsolute(self) -> None:
+        t = Thread(spec_for_testing(b'''
+            <html><body>
+              <div class="post-navheader">
+                <a class="view-button-link" href="https://elsewhere/posts/4567"><div class="view-button">Next Post &raquo;</div>
+                </a><a class="view-button-link" href="https://elsewhere/posts/4321"><div class="view-button float-none">&laquo; Previous Post</div>
+                </a>
+              </div>
+              <div class="post-container post-post">The "post"</div>
+            </body></html>'''))
+        self.assertEqual(t.next_thread(), 'https://elsewhere/posts/4567')
+
 
 if __name__ == '__main__':
     unittest.main()