Firebase API
This package contains tests of the integreat_cms.firebase_api
app
Test Firebase API Client
- class tests.firebase_api.test_firebase_api_client.TestFirebaseApiClient[source]
Bases:
object
Test for
FirebaseApiClient
Only tests the correct result (
True
/False
) and logging output depending on the firebase-HTTP response. It does not test if firebase-api-server works/answers as expected.- response_mock_data = {'200_no_message_id': {'reason': '', 'status_code': 200}, '200_success': {'message_id': 1, 'reason': '', 'status_code': 200}, '401_invalid_key': {'reason': 'invalid key', 'status_code': 401}, '404': {'reason': '', 'status_code': 404}}[source]
A set of response-data for the mocking-function according to https://fcm.googleapis.com/fcm/send
- send_all_with_mocked_response(settings: SettingsWrapper, requests_mock: Mocker, mocked_response: dict[str, Any]) bool [source]
Fires a
send_all()
with mocked post- Parameters:
settings (SettingsWrapper) – The Django settings
requests_mock (Mocker) – Fixture for mocking requests, see pytest
mocked_response (dict[str, Any]) – Data for the mocked response, depending on test-scenario (given by
response_mock_data
)
- Returns:
Success status of the notification sending
- Return type:
- test_client_throws_exception_when_fcm_disabled(settings: SettingsWrapper, load_test_data: None) None [source]
Tests that an ImproperlyConfigured exception is thrown, if firebase API is disabled in settings
- Parameters:
settings (SettingsWrapper) – The Django settings
load_test_data (None) – The fixture providing the test data (see
load_test_data()
)
- Return type:
None
- test_firebase_api_200_success(settings: SettingsWrapper, load_test_data: None, requests_mock: Mocker, caplog: LogCaptureFixture) None [source]
Tests firebase-api-response handling, test a successful API call
- Parameters:
settings (SettingsWrapper) – The Django settings
load_test_data (None) – The fixture providing the test data (see
load_test_data()
)requests_mock (Mocker) – Fixture for mocking requests, see pytest
caplog (LogCaptureFixture) – Fixture for asserting log messages in tests (see
caplog
)
- Return type:
None
- test_firebase_api_200_unexpected_api_response(settings: SettingsWrapper, load_test_data: None, requests_mock: Mocker, caplog: LogCaptureFixture) None [source]
Tests firebase-api-response handling, test a partial successful api call - HTTP 200 but no message_id in response
- Parameters:
settings (SettingsWrapper) – The Django settings
load_test_data (None) – The fixture providing the test data (see
load_test_data()
)requests_mock (Mocker) – Fixture for mocking requests, see pytest
caplog (LogCaptureFixture) – Fixture for asserting log messages in tests (see
caplog
)
- Return type:
None
- test_firebase_api_403_wrong_token(settings: SettingsWrapper, load_test_data: None, requests_mock: Mocker, caplog: LogCaptureFixture) None [source]
Tests firebase-api-response handling, test a denied call - HTTP 403 because of wrong auth-token
- Parameters:
settings (SettingsWrapper) – The Django settings
load_test_data (None) – The fixture providing the test data (see
load_test_data()
)requests_mock (Mocker) – Fixture for mocking requests, see pytest
caplog (LogCaptureFixture) – Fixture for asserting log messages in tests (see
caplog
)
- Return type:
None
- test_firebase_api_404(settings: SettingsWrapper, load_test_data: None, requests_mock: Mocker, caplog: LogCaptureFixture) None [source]
Tests firebase-api-response handling, test 404 response
- Parameters:
settings (SettingsWrapper) – The Django settings
load_test_data (None) – The fixture providing the test data (see
load_test_data()
)requests_mock (Mocker) – Fixture for mocking requests, see pytest
caplog (LogCaptureFixture) – Fixture for asserting log messages in tests (see
caplog
)
- Return type:
None
- test_is_invalid_when_no_title(settings: SettingsWrapper, load_test_data: None) None [source]
Tests that
is_valid()
isFalse
, when pushNotification-title is missing- Parameters:
settings (SettingsWrapper) – The Django settings
load_test_data (None) – The fixture providing the test data (see
load_test_data()
)
- Return type:
None
- test_is_invalid_when_no_translation(settings: SettingsWrapper, load_test_data: None) None [source]
Tests that
is_valid()
isFalse
, when translation missing- Parameters:
settings (SettingsWrapper) – The Django settings
load_test_data (None) – The fixture providing the test data (see
load_test_data()
)
- Return type:
None
- test_is_valid(settings: SettingsWrapper, load_test_data: None) None [source]
Tests that
is_valid()
isTrue
, when FCM_ENABLED and pushNotification valid (with title and translation)- Parameters:
settings (SettingsWrapper) – The Django settings
load_test_data (None) – The fixture providing the test data (see
load_test_data()
)
- Return type:
None