Utils

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

Test Content Utils

Test Disable Hix Post Save Signal

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

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

tests.cms.utils.test_translation_utils.test_translate_link() None[source]

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

Return type:

None