]> git.scottworley.com Git - paperdoorknob/blobdiff - glowfic_test.py
Move per-thread processing stuff into Thread
[paperdoorknob] / glowfic_test.py
index 68debf91cc82a719bec4f3f2ed391db6dc25f5e6..bd26e3c9dfc5bc0ee4ec02eead21e34bdca42689 100644 (file)
@@ -16,8 +16,9 @@ from texify import PandocTexifier
 
 
 def spec_for_testing(html: bytes) -> Spec:
-    return Spec('test',
-                FakeFetcher({'test': html, '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,7 +103,7 @@ class TestThread(unittest.TestCase):
             </body></html>'''))
         self.assertEqual(t.title(), 'Teh Story!')
 
-    def testNextThread(self) -> None:
+    def testNextThreadRelative(self) -> None:
         t = Thread(spec_for_testing(b'''
             <html><body>
               <div class="post-navheader">
@@ -112,7 +113,19 @@ class TestThread(unittest.TestCase):
               </div>
               <div class="post-container post-post">The "post"</div>
             </body></html>'''))
-        self.assertEqual(t.next_thread(), '/posts/4567')
+        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__':