+# paperdoorknob: Print glowfic
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation, version 3.
+
+
+import unittest
+
+from bs4 import BeautifulSoup
+
+from glowfic import chunkDOMs
+
+
+class TestSplit(unittest.TestCase):
+
+ def testSplit1(self) -> None:
+ soup = BeautifulSoup(b'''
+ <html><body><div class="post-container post-post">
+ The "post"
+ </div></body></html>''', 'html.parser')
+ self.assertEqual([list(t.stripped_strings) for t in chunkDOMs(soup)],
+ [['The "post"']])
+
+ def testSplit2(self) -> None:
+ soup = BeautifulSoup(b'''
+ <html><body>
+ <div class="post-container post-post">The "post"</div>
+ <div class="flat-post-replies">
+ <div class="post-container post-reply">The "reply"</div>
+ </div>
+ </body></html>''', 'html.parser')
+ self.assertEqual([list(t.stripped_strings) for t in chunkDOMs(soup)],
+ [['The "post"'], ['The "reply"']])
+
+ def testSplit3(self) -> None:
+ soup = BeautifulSoup(b'''
+ <html><body>
+ <div class="post-container post-post">The "post"</div>
+ <div class="flat-post-replies">
+ <div class="post-container post-reply">1st reply</div>
+ <div class="post-container post-reply">2nd reply</div>
+ </div>
+ </body></html>''', 'html.parser')
+ self.assertEqual([list(t.stripped_strings) for t in chunkDOMs(soup)],
+ [['The "post"'], ['1st reply'], ['2nd reply']])
+
+
+if __name__ == '__main__':
+ unittest.main()