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
- Firebase API
- Mt API
- Sitemap
- SUMM.AI API
- 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.ANONYMOUS: Final = 'ANONYMOUS'[source]
A role identifier for anonymous users
- 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.ROOT: Final = 'ROOT'[source]
A role identifier for superusers
- 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.pytest_plugins: Final = 'aiohttp.pytest_plugin'[source]
Enable the aiohttp pytest plugin to make use of the test server
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