from django.test import TestCase from bookwyrm.sanitize_html import InputHtmlParser class Sanitizer(TestCase): def test_no_html(self): input_text = 'no html ' parser = InputHtmlParser() parser.feed(input_text) output = parser.get_output() self.assertEqual(input_text, output) def test_valid_html(self): input_text = 'yes html' parser = InputHtmlParser() parser.feed(input_text) output = parser.get_output() self.assertEqual(input_text, output) def test_valid_html_attrs(self): input_text = 'yes html' parser = InputHtmlParser() parser.feed(input_text) output = parser.get_output() self.assertEqual(input_text, output) def test_invalid_html(self): input_text = 'yes html' parser = InputHtmlParser() parser.feed(input_text) output = parser.get_output() self.assertEqual('yes html', output) input_text = 'yes html ' parser = InputHtmlParser() parser.feed(input_text) output = parser.get_output() self.assertEqual('yes html ', output) def test_disallowed_html(self): input_text = '
yes html
' parser = InputHtmlParser() parser.feed(input_text) output = parser.get_output() self.assertEqual(' yes html', output)