mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
Add test coverage for parsers in tools/lib.
Now, `tools/test-all` calls a new program called `tools/tests-tools` that runs unit tests in `test_css_parser.py` and 'test_template_parser.py`. This puts 100% line coverage on tools/lib/css_parser.py. This puts about 50% line coverage on tools/lib/template_parser.py.
This commit is contained in:
34
tools/tests/test_template_parser.py
Normal file
34
tools/tests/test_template_parser.py
Normal file
@@ -0,0 +1,34 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import print_function
|
||||
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
try:
|
||||
from tools.lib.template_parser import (
|
||||
is_django_block_tag,
|
||||
validate,
|
||||
)
|
||||
except ImportError:
|
||||
print('ERROR!!! You need to run this via tools/test-tools.')
|
||||
sys.exit(1)
|
||||
|
||||
class ParserTest(unittest.TestCase):
|
||||
def test_is_django_block_tag(self):
|
||||
# type: () -> None
|
||||
self.assertTrue(is_django_block_tag('block'))
|
||||
self.assertFalse(is_django_block_tag('not a django tag'))
|
||||
|
||||
def test_validate_vanilla_html(self):
|
||||
# type: () -> None
|
||||
'''
|
||||
Verify that validate() does not raise errors for
|
||||
well-formed HTML.
|
||||
'''
|
||||
my_html = '''
|
||||
<table>
|
||||
<tr>
|
||||
<td>foo</td>
|
||||
</tr>
|
||||
</table>'''
|
||||
validate(text=my_html)
|
||||
Reference in New Issue
Block a user