Tests
We use pytest to validate that the functionality of the cms works as expected.
In addition, we use the following plugins:
pytest-cov: This plugin produces coverage reports.
pytest-django: Provide a few helpers for Django
pytest-xdist: Enable distributing tests across multiple CPUs to speed up test execution
Welcome to requests-mock’s documentation!: Mocking requests to external APIs
For more information, see Testing in Django and Writing and running tests.
- API
- CMS
- Utils
- Views
- Status Code
- Test View Status Code_1
- Test View Status Code_10
- Test View Status Code_11
- Test View Status Code_12
- Test View Status Code_13
- Test View Status Code_14
- Test View Status Code_15
- Test View Status Code_16
- Test View Status Code_2
- Test View Status Code_3
- Test View Status Code_4
- Test View Status Code_5
- Test View Status Code_6
- Test View Status Code_7
- Test View Status Code_8
- Test View Status Code_9
- Test Public View Status Code
- Test View Redirect
- Utils
- View Config
- Status Code
- Test Duplicate Regions
- Test Language
- Test Login
- Test Media Library
- Test Page Filters
- Core
- Deepl API
- Deepl API Test
get_content_translations()
get_word_count()
setup_deepl_supported_languages()
setup_fake_deepl_api_server()
test_deepl_bulk_mt_api_error()
test_deepl_bulk_mt_events()
test_deepl_bulk_mt_exceeds_limit()
test_deepl_bulk_mt_no_source_language()
test_deepl_bulk_mt_no_target_language()
test_deepl_bulk_mt_pages()
test_deepl_bulk_mt_pois()
test_deepl_bulk_mt_up_to_date()
test_deepl_bulk_mt_up_to_date_and_ready_for_mt()
test_deepl_event_automatic_translation()
test_deepl_page_automatic_translation()
test_deepl_poi_automatic_translation()
- Deepl API Test
- Firebase API
- Test Firebase API Client
TestFirebaseApiClient
TestFirebaseApiClient.__init__()
TestFirebaseApiClient.response_mock_data
TestFirebaseApiClient.send_all_with_mocked_response()
TestFirebaseApiClient.setup_method()
TestFirebaseApiClient.teardown_method()
TestFirebaseApiClient.test_client_throws_exception_when_fcm_disabled()
TestFirebaseApiClient.test_firebase_api_200_success()
TestFirebaseApiClient.test_firebase_api_200_unexpected_api_response()
TestFirebaseApiClient.test_firebase_api_403_wrong_token()
TestFirebaseApiClient.test_firebase_api_404()
TestFirebaseApiClient.test_is_invalid_when_no_title()
TestFirebaseApiClient.test_is_invalid_when_no_translation()
TestFirebaseApiClient.test_is_valid()
TestFirebaseApiClient.test_multiple_regions_notification_send()
TestFirebaseApiClient.test_region_notification_send()
- Test Firebase API Client
- Sitemap
- SUMM.AI API
- SUMM.AI Test
attempts
test_auto_translate_easy_german()
test_check_rate_limit_exceeded()
test_missing_translation()
test_patient_task_queue_hit_rate_limit()
test_patient_task_queue_max_retries()
test_patient_task_queue_normal_deque()
test_summ_ai_error_handling()
test_translate_text_field_ddos_defense()
test_translate_text_field_hit_rate_limit()
test_translate_text_field_internal_server_error()
test_translate_text_field_successful_translation()
test_translate_text_forbidden()
test_translate_text_with_empty_text_field()
test_unexpected_html()
test_validate_response_invalid()
test_validate_response_valid()
test_worker()
- Utils
- SUMM.AI Test
- XLIFF
Conftest
This module contains shared fixtures for pytest
- tests.conftest.ALL_ROLES: Final = ['MANAGEMENT', 'EDITOR', 'AUTHOR', 'EVENT_MANAGER', 'OBSERVER', 'ROOT', 'SERVICE_TEAM', 'CMS_TEAM', 'APP_TEAM', 'MARKETING_TEAM', 'ANONYMOUS'][source]
All region and staff roles and anonymous users
[ 'MANAGEMENT', 'EDITOR', 'AUTHOR', 'EVENT_MANAGER', 'OBSERVER', 'ROOT', 'SERVICE_TEAM', 'CMS_TEAM', 'APP_TEAM', 'MARKETING_TEAM', 'ANONYMOUS', ]
- tests.conftest.HIGH_PRIV_STAFF_ROLES: Final = ['ROOT', 'SERVICE_TEAM', 'CMS_TEAM'][source]
All roles of staff users that don’t just have read-only permissions
['ROOT', 'SERVICE_TEAM', 'CMS_TEAM']
- tests.conftest.PRIV_STAFF_ROLES: Final = ['ROOT', 'APP_TEAM', 'SERVICE_TEAM', 'CMS_TEAM'][source]
All roles of staff users that don’t just have read-only permissions
['ROOT', 'APP_TEAM', 'SERVICE_TEAM', 'CMS_TEAM']
- tests.conftest.REGION_ROLES: Final = ['MANAGEMENT', 'EDITOR', 'AUTHOR', 'EVENT_MANAGER', 'OBSERVER'][source]
All roles of region users
['MANAGEMENT', 'EDITOR', 'AUTHOR', 'EVENT_MANAGER', 'OBSERVER']
- tests.conftest.ROLES: Final = ['MANAGEMENT', 'EDITOR', 'AUTHOR', 'EVENT_MANAGER', 'OBSERVER', 'ROOT', 'SERVICE_TEAM', 'CMS_TEAM', 'APP_TEAM', 'MARKETING_TEAM'][source]
All region and staff roles
[ 'MANAGEMENT', 'EDITOR', 'AUTHOR', 'EVENT_MANAGER', 'OBSERVER', 'ROOT', 'SERVICE_TEAM', 'CMS_TEAM', 'APP_TEAM', 'MARKETING_TEAM', ]
- tests.conftest.STAFF_ROLES: Final = ['ROOT', 'SERVICE_TEAM', 'CMS_TEAM', 'APP_TEAM', 'MARKETING_TEAM'][source]
All roles of staff users
['ROOT', 'SERVICE_TEAM', 'CMS_TEAM', 'APP_TEAM', 'MARKETING_TEAM']
- tests.conftest.WRITE_ROLES: Final = ['MANAGEMENT', 'EDITOR', 'AUTHOR', 'EVENT_MANAGER'][source]
All roles with editing permissions
['MANAGEMENT', 'EDITOR', 'AUTHOR', 'EVENT_MANAGER']
- tests.conftest.load_test_data(django_db_setup: None, django_db_blocker: _DatabaseBlocker) None [source]
Load the test data initially for all test cases
- Parameters:
django_db_setup (None) – The fixture providing the database availability
django_db_blocker (_DatabaseBlocker) – The fixture providing the database blocker
- Return type:
None
- tests.conftest.load_test_data_transactional(transactional_db: None, django_db_blocker: _DatabaseBlocker) None [source]
Load the test data initially for all transactional test cases
- Parameters:
transactional_db (None) – The fixture providing transaction support for the database
django_db_blocker (_DatabaseBlocker) – The fixture providing the database blocker
- Return type:
None
- tests.conftest.login_role_user(request: SubRequest, load_test_data: None, django_db_blocker: _DatabaseBlocker) tuple[Client, str] [source]
Get the test user of the current role and force a login. Gets executed only once per user.
- Parameters:
request (SubRequest) – The request object providing the parametrized role variable through
request.param
load_test_data (None) – The fixture providing the test data (see
load_test_data()
)django_db_blocker (_DatabaseBlocker) – The fixture providing the database blocker
- Returns:
The http client and the current role
- Return type:
- tests.conftest.login_role_user_async(request: SubRequest, load_test_data: None, django_db_blocker: _DatabaseBlocker) tuple[AsyncClient, str] [source]
Get the test user of the current role and force a login. Gets executed only once per user. Identical to
login_role_user()
with the difference that it returns andjango.test.client.AsyncClient
instead ofdjango.test.client.Client
.- Parameters:
request (SubRequest) – The request object providing the parametrized role variable through
request.param
load_test_data (None) – The fixture providing the test data (see
load_test_data()
)django_db_blocker (_DatabaseBlocker) – The fixture providing the database blocker
- Returns:
The http client and the current role
- Return type:
- tests.conftest.mock_server(httpserver: HTTPServer) MockServer [source]
- Parameters:
httpserver (HTTPServer) –
- Return type:
Mock
- class tests.mock.MockServer(http_server: HTTPServer)[source]
Bases:
object
Http server instance that allowes to configure mock responses
- Parameters:
http_server (HTTPServer) –
- __init__(http_server: HTTPServer) None [source]
- Parameters:
http_server (HTTPServer) –
- Return type:
None
Utils
This file contains helper functions for tests.
- tests.utils.assert_message_in_log(message: str, caplog: LogCaptureFixture) None [source]
Check whether a given message is in the messages div
- Parameters:
- Raises:
AssertionError – When the expected message was not found in the logs
- Return type:
None
- tests.utils.assert_no_error_messages(caplog: LogCaptureFixture) None [source]
Assert that no error messages were shown to the user
- Parameters:
caplog (LogCaptureFixture) – The
caplog
fixture- Raises:
AssertionError – When the the logs contains error messages
- Return type:
None