Test helpers

HTML assertions

class openforms.utils.tests.html_assert.HTMLAssertMixin

Mixin HTML-related assertions.

assertHTMLValid(html_text)

check basic HTML syntax validity

assertNotTagWithTextIn(tag, text, document_str)

check for html tags and their content while ignoring tag attributes

assertTagWithTextIn(tag, text, document_str)

check for html tags and their content while ignoring tag attributes

openforms.utils.tests.html_assert.strip_all_attributes(document: str) str

Reduce an HTML document to just the tags, stripping any attributes.

Useful for testing with self.assertInHTML without having to worry about class names, style tags etc.

Taken and adapted from https://stackoverflow.com/a/7472003

class openforms.utils.tests.webtest_base.WebTestPyQueryMixin

Mixin PyQuery assertions for WebTest tests.

Migrations

class openforms.utils.tests.test_migrations.TestMigrations(methodName='runTest')

Test the effect of applying a migration

Adapted from https://www.caktusgroup.com/blog/2016/02/02/writing-unit-tests-django-migrations/

setUp()

Hook method for setting up the test fixture before exercising it.

Formio assertions

class openforms.formio.tests.assertions.FormioMixin
assertFormioComponent(configuration: Dict[str, Union[str, int, None, float, bool, Dict[str, Union[str, int, None, float, bool, JSONObject, List[Union[str, int, None, float, bool, JSONObject, List[JSONValue]]]]], List[Union[str, int, None, float, bool, Dict[str, Union[str, int, None, float, bool, JSONObject, List[JSONValue]]], List[JSONValue]]]]], key: str, properties_map: Dict[str, Union[str, int, None, float, bool, Dict[str, Union[str, int, None, float, bool, JSONObject, List[Union[str, int, None, float, bool, JSONObject, List[JSONValue]]]]], List[Union[str, int, None, float, bool, Dict[str, Union[str, int, None, float, bool, JSONObject, List[JSONValue]]], List[JSONValue]]]]]) None

Assert that the formio component with specified key has the expected properties.

Parameters
  • configuration – Formio form configuration

  • key – the unique key of the component to check

  • properties_map – a mapping of formio property name to expected property value. Note that the dict keys can be dotted paths for nested properties.