Utils

This package contains tests for the integreat_cms.cms.utils package.

Test Content Utils

tests.cms.utils.test_content_utils.test_clean_content(load_test_data: None, login_role_user: tuple[Client, str]) None[source]
Parameters:
Return type:

None

Test Disable Hix Post Save Signal

tests.cms.utils.test_disable_hix_post_save_signal.create_dummy_page_translation(dummy_region: Region) PageTranslation[source]
Parameters:

dummy_region (Region)

Return type:

PageTranslation

tests.cms.utils.test_disable_hix_post_save_signal.dummy_region(django_db_setup: None, django_db_blocker: _DatabaseBlocker) Region[source]

Fixture to create a dummy region, along with a dummy language.

Parameters:
  • django_db_setup (None)

  • django_db_blocker (_DatabaseBlocker)

Return type:

Region

tests.cms.utils.test_disable_hix_post_save_signal.test_disable_hix_post_save_signal(dummy_region: Region) None[source]
Parameters:

dummy_region (Region)

Return type:

None

tests.cms.utils.test_disable_hix_post_save_signal.test_rule_out_false_positive(dummy_region: Region) None[source]
Parameters:

dummy_region (Region)

Return type:

None

Test External Calendar Utils

tests.cms.utils.test_external_calendar_utils.test_import_fails(calendar_data: tuple[str, str]) None[source]

Tests that invalid calendars cannot be imported and that the import fails with the correct error message :param calendar_data: A tuple of calendar path and expected error message

Parameters:

calendar_data (tuple[str, str])

Return type:

None

Test Repair Tree

Test repair tree util

Test execution order: Since there seem to be some weird side effects happening for unrelated tests when testing database consistency, we first run those, then the tests that make sure the repair_tree() is effective, and last the effectiveness of tree_mutex() itself. This ordering is facilitated using pytest_order to specify the tests to run "last" (eqivalent to -1, absolute ordering) and after certain other tests (relative ordering).

See https://pytest-order.readthedocs.io/en/stable/usage.html#order-relative-to-other-tests

tests.cms.utils.test_repair_tree.test_repair_tree(load_test_data_transactional: None) None[source]

Create a broken tree of 3 nodes and assert that repair_tree() correctly fixes it.

Parameters:

load_test_data_transactional (None)

Return type:

None

tests.cms.utils.test_repair_tree.test_repair_tree_complex(load_test_data_transactional: None) None[source]

Recreate a real-world example of a broken tree and assert that repair_tree() correctly fixes it.

Parameters:

load_test_data_transactional (None)

Return type:

None

Test Rounded Hix Value

tests.cms.utils.test_rounded_hix_value.test_rounded_hix_value(raw_hix_expected_rounding: tuple[float, float]) None[source]

Test to check HIX scores are rounded correctly

Parameters:

raw_hix_expected_rounding (tuple[float, float])

Return type:

None

Test Slug Utils

tests.cms.utils.test_slug_utils.test_generate_unique_slug_fallback(settings: SettingsWrapper, load_test_data: None) None[source]

Test whether the generate_unique_slug_helper() function correctly uses the fallback property when no slug is provided

Parameters:
  • settings (SettingsWrapper)

  • load_test_data (None)

Return type:

None

tests.cms.utils.test_slug_utils.test_generate_unique_slug_no_fallback() None[source]

Test whether the generate_unique_slug_helper() throws a django.core.exceptions.ValidationError, while the fallback property does not exist

Return type:

None

tests.cms.utils.test_slug_utils.test_generate_unique_slug_reserved_page_slug(settings: SettingsWrapper, load_test_data: None) None[source]

Test whether the generate_unique_slug_helper() function function returns the correct unique slug when the new page slug is a reserved slug

Parameters:
  • settings (SettingsWrapper)

  • load_test_data (None)

Return type:

None

tests.cms.utils.test_slug_utils.test_generate_unique_slug_reserved_region_slug(settings: SettingsWrapper, load_test_data: None) None[source]

Test whether the generate_unique_slug_helper() function returns the correct unique slug when the new region slug is a reserved slug

Parameters:
  • settings (SettingsWrapper)

  • load_test_data (None)

Return type:

None

Test Translation Utils

Test whether the translate_link() function correctly escapes message text while preserving the link tags

Return type:

None