Improve and test html sanitisation
This commit is contained in:
parent
0bfec5d046
commit
85ebfef44a
4 changed files with 241 additions and 3 deletions
24
tests/unit_tests/test_ui.py
Normal file
24
tests/unit_tests/test_ui.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
"""Testing the server specified user interface."""
|
||||
|
||||
import os
|
||||
|
||||
import pytest
|
||||
|
||||
from openflexure_microscope_server import ui
|
||||
|
||||
from ..shared_utils.md_test_cases import find_test_cases
|
||||
|
||||
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
HTML_SANITISATION_TEST_FILE = os.path.join(
|
||||
THIS_DIR, "data", "html_sanitisation_test_cases.md"
|
||||
)
|
||||
HTML_SANITISATION_TEST_CASES = find_test_cases(HTML_SANITISATION_TEST_FILE, "html")
|
||||
|
||||
|
||||
@pytest.mark.parametrize("test_case", HTML_SANITISATION_TEST_CASES)
|
||||
def test_html_block_sanitises(test_case):
|
||||
"""Check each case in the test case file sanitises as expected."""
|
||||
sanitised = ui.sanitise_html(test_case.input_code).strip()
|
||||
assert sanitised == test_case.result_code, (
|
||||
f"Test case: '{test_case.title}': Input code doesn't sanitise as expected."
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue