]> git.scottworley.com Git - paperdoorknob/blob - domfilter_test.py
Reify Layout
[paperdoorknob] / domfilter_test.py
1 # paperdoorknob: Print glowfic
2 #
3 # This program is free software: you can redistribute it and/or modify it
4 # under the terms of the GNU General Public License as published by the
5 # Free Software Foundation, version 3.
6
7
8 import unittest
9
10 from bs4 import BeautifulSoup
11
12 from domfilter import ApplyDOMFilters
13
14
15 class TestDOMFilters(unittest.TestCase):
16
17 def setUp(self) -> None:
18 self._html = BeautifulSoup(b'''
19 <div class="post-container post-post">
20 <div class="post-edit-box">This is the edit box</div>
21 This is glowfic
22 <div class="post-footer">This is the footer</div>
23 </div>''', 'html.parser')
24
25 def testStripFooters(self) -> None:
26 ApplyDOMFilters("NoFooter", self._html)
27 self.assertEqual(list(self._html.stripped_strings),
28 ["This is the edit box", "This is glowfic"])
29
30 def testStripEditBoxes(self) -> None:
31 ApplyDOMFilters("NoEdit", self._html)
32 self.assertEqual(list(self._html.stripped_strings),
33 ["This is glowfic", "This is the footer"])
34
35 def testStripFootersAndEditBoxes(self) -> None:
36 ApplyDOMFilters("NoEdit,NoFooter", self._html)
37 self.assertEqual(list(self._html.stripped_strings),
38 ["This is glowfic"])
39
40
41 if __name__ == '__main__':
42 unittest.main()