Open source video conferencing app powered by LiveKit. Built with Django and React.
♻️(backend) avoid repeating 'service' in python modules
lebaudantoinefbee41f5dd76
diff --git a/src/backend/core/api/viewsets.py b/src/backend/core/api/viewsets.pyindex 92222621..d38994b1 100644--- a/src/backend/core/api/viewsets.py+++ b/src/backend/core/api/viewsets.py@@ -39,11 +39,11 @@ from core.recording.worker.factories import (from core.recording.worker.mediator import (WorkerServiceMediator,)-from core.services.livekit_events_service import (+from core.services.livekit_events import (LiveKitEventsService,LiveKitWebhookError,)-from core.services.lobby_service import (+from core.services.lobby import (LobbyParticipantNotFound,LobbyService,)diff --git a/src/backend/core/authentication/backends.py b/src/backend/core/authentication/backends.pyindex 46fa366f..71c6d21a 100644--- a/src/backend/core/authentication/backends.py+++ b/src/backend/core/authentication/backends.py@@ -10,7 +10,7 @@ from mozilla_django_oidc.auth import ()from core.models import User-from core.services.marketing_service import (+from core.services.marketing import (ContactCreationError,ContactData,get_marketing_service,diff --git a/src/backend/core/services/livekit_events_service.py b/src/backend/core/services/livekit_events.pysimilarity index 98%rename from src/backend/core/services/livekit_events_service.pyrename to src/backend/core/services/livekit_events.pyindex d40a42ed..b4cf9866 100644--- a/src/backend/core/services/livekit_events_service.py+++ b/src/backend/core/services/livekit_events.py@@ -7,7 +7,7 @@ from django.conf import settingsfrom livekit import api-from .lobby_service import LobbyService+from .lobby import LobbyServiceclass LiveKitWebhookError(Exception):diff --git a/src/backend/core/services/lobby_service.py b/src/backend/core/services/lobby.pysimilarity index 100%rename from src/backend/core/services/lobby_service.pyrename to src/backend/core/services/lobby.pydiff --git a/src/backend/core/services/marketing_service.py b/src/backend/core/services/marketing.pysimilarity index 100%rename from src/backend/core/services/marketing_service.pyrename to src/backend/core/services/marketing.pydiff --git a/src/backend/core/tests/authentication/test_backends.py b/src/backend/core/tests/authentication/test_backends.pyindex 750b46c0..576f9c0d 100644--- a/src/backend/core/tests/authentication/test_backends.py+++ b/src/backend/core/tests/authentication/test_backends.py@@ -9,7 +9,7 @@ import pytestfrom core import modelsfrom core.authentication.backends import OIDCAuthenticationBackendfrom core.factories import UserFactory-from core.services import marketing_service+from core.services import marketingpytestmark = pytest.mark.django_db@@ -535,7 +535,7 @@ def test_marketing_signup_handles_service_initialization_errors(@pytest.mark.parametrize("error",[- marketing_service.ContactCreationError,+ marketing.ContactCreationError,ImproperlyConfigured,ImportError,],diff --git a/src/backend/core/tests/rooms/test_api_rooms_lobby.py b/src/backend/core/tests/rooms/test_api_rooms_lobby.pyindex d7442734..25034a4b 100644--- a/src/backend/core/tests/rooms/test_api_rooms_lobby.py+++ b/src/backend/core/tests/rooms/test_api_rooms_lobby.py@@ -14,7 +14,7 @@ from rest_framework.test import APIClientfrom ... import utilsfrom ...factories import RoomFactory, UserFactoryfrom ...models import RoomAccessLevel-from ...services.lobby_service import (+from ...services.lobby import (LobbyService,)diff --git a/src/backend/core/tests/rooms/test_api_rooms_webhook.py b/src/backend/core/tests/rooms/test_api_rooms_webhook.pyindex 7b0cb7f1..bbac4328 100644--- a/src/backend/core/tests/rooms/test_api_rooms_webhook.py+++ b/src/backend/core/tests/rooms/test_api_rooms_webhook.py@@ -12,7 +12,7 @@ from unittest import mockimport pytestfrom livekit import api-from ...services.livekit_events_service import ActionFailedError, LiveKitEventsService+from ...services.livekit_events import ActionFailedError, LiveKitEventsService@pytest.fixturediff --git a/src/backend/core/tests/services/test_livekit_events_service.py b/src/backend/core/tests/services/test_livekit_events.pysimilarity index 97%rename from src/backend/core/tests/services/test_livekit_events_service.pyrename to src/backend/core/tests/services/test_livekit_events.pyindex c55762b1..0a78d0a7 100644--- a/src/backend/core/tests/services/test_livekit_events_service.py+++ b/src/backend/core/tests/services/test_livekit_events.py@@ -8,7 +8,7 @@ from unittest import mockimport pytest-from core.services.livekit_events_service import (+from core.services.livekit_events import (ActionFailedError,AuthenticationError,InvalidPayloadError,@@ -16,7 +16,7 @@ from core.services.livekit_events_service import (UnsupportedEventTypeError,api,)-from core.services.lobby_service import LobbyService+from core.services.lobby import LobbyServicepytestmark = pytest.mark.django_dbdiff --git a/src/backend/core/tests/services/test_lobby_service.py b/src/backend/core/tests/services/test_lobby.pysimilarity index 95%rename from src/backend/core/tests/services/test_lobby_service.pyrename to src/backend/core/tests/services/test_lobby.pyindex 6a553853..1382aa05 100644--- a/src/backend/core/tests/services/test_lobby_service.py+++ b/src/backend/core/tests/services/test_lobby.py@@ -18,7 +18,7 @@ from livekit.api import TwirpErrorfrom core.factories import RoomFactoryfrom core.models import RoomAccessLevel-from core.services.lobby_service import (+from core.services.lobby import (LobbyNotificationError,LobbyParticipant,LobbyParticipantNotFound,@@ -309,7 +309,7 @@ def test_request_entry_trusted_room(lobby_service._get_participant.assert_called_once_with(room.id, participant_id)[email protected]("core.services.lobby_service.LobbyService.enter")[email protected]("core.services.lobby.LobbyService.enter")def test_request_entry_new_participant(mock_enter, lobby_service, participant_id, username):@@ -338,7 +338,7 @@ def test_request_entry_new_participant(lobby_service._get_participant.assert_called_once_with(room.id, participant_id)[email protected]("core.services.lobby_service.LobbyService.refresh_waiting_status")[email protected]("core.services.lobby.LobbyService.refresh_waiting_status")def test_request_entry_waiting_participant(mock_refresh, lobby_service, participant_id, username):@@ -400,7 +400,7 @@ def test_request_entry_accepted_participant(lobby_service._get_participant.assert_called_once_with(room.id, participant_id)[email protected]("core.services.lobby_service.cache")[email protected]("core.services.lobby.cache")def test_refresh_waiting_status(mock_cache, lobby_service, participant_id):"""Test refreshing waiting status for a participant."""lobby_service._get_cache_key = mock.Mock(return_value="mocked_cache_key")@@ -412,9 +412,9 @@ def test_refresh_waiting_status(mock_cache, lobby_service, participant_id):# pylint: disable=R0917[email protected]("core.services.lobby_service.cache")[email protected]("core.services.lobby.cache")@mock.patch("core.utils.generate_color")[email protected]("core.services.lobby_service.LobbyService.notify_participants")[email protected]("core.services.lobby.LobbyService.notify_participants")def test_enter_success(mock_notify,mock_generate_color,@@ -447,9 +447,9 @@ def test_enter_success(# pylint: disable=R0917[email protected]("core.services.lobby_service.cache")[email protected]("core.services.lobby.cache")@mock.patch("core.utils.generate_color")[email protected]("core.services.lobby_service.LobbyService.notify_participants")[email protected]("core.services.lobby.LobbyService.notify_participants")def test_enter_with_notification_error(mock_notify,mock_generate_color,@@ -479,7 +479,7 @@ def test_enter_with_notification_error()[email protected]("core.services.lobby_service.cache")[email protected]("core.services.lobby.cache")def test_get_participant_not_found(mock_cache, lobby_service, participant_id):"""Test getting a participant that doesn't exist."""mock_cache.get.return_value = None@@ -494,8 +494,8 @@ def test_get_participant_not_found(mock_cache, lobby_service, participant_id):mock_cache.get.assert_called_once_with("mocked_cache_key")[email protected]("core.services.lobby_service.cache")[email protected]("core.services.lobby_service.LobbyParticipant.from_dict")[email protected]("core.services.lobby.cache")[email protected]("core.services.lobby.LobbyParticipant.from_dict")def test_get_participant_parsing_error(mock_from_dict, mock_cache, lobby_service, participant_id):@@ -512,7 +512,7 @@ def test_get_participant_parsing_error(mock_cache.delete.assert_called_once_with("mocked_cache_key")[email protected]("core.services.lobby_service.cache")[email protected]("core.services.lobby.cache")def test_list_waiting_participants_empty(mock_cache, lobby_service):"""Test listing waiting participants when none exist."""mock_cache.keys.return_value = []@@ -526,7 +526,7 @@ def test_list_waiting_participants_empty(mock_cache, lobby_service):mock_cache.get_many.assert_not_called()[email protected]("core.services.lobby_service.cache")[email protected]("core.services.lobby.cache")def test_list_waiting_participants(mock_cache, lobby_service, participant_dict):"""Test listing waiting participants with valid data."""room = RoomFactory(access_level=RoomAccessLevel.RESTRICTED)@@ -544,7 +544,7 @@ def test_list_waiting_participants(mock_cache, lobby_service, participant_dict):mock_cache.get_many.assert_called_once_with([cache_key])[email protected]("core.services.lobby_service.cache")[email protected]("core.services.lobby.cache")def test_list_waiting_participants_multiple(mock_cache, lobby_service):"""Test listing multiple waiting participants with valid data."""room = RoomFactory(access_level=RoomAccessLevel.RESTRICTED)@@ -587,7 +587,7 @@ def test_list_waiting_participants_multiple(mock_cache, lobby_service):mock_cache.get_many.assert_called_once_with([cache_key1, cache_key2])[email protected]("core.services.lobby_service.cache")[email protected]("core.services.lobby.cache")def test_list_waiting_participants_corrupted_data(mock_cache, lobby_service):"""Test listing waiting participants with corrupted data."""room = RoomFactory(access_level=RoomAccessLevel.RESTRICTED)@@ -601,7 +601,7 @@ def test_list_waiting_participants_corrupted_data(mock_cache, lobby_service):mock_cache.delete.assert_called_once_with(cache_key)[email protected]("core.services.lobby_service.cache")[email protected]("core.services.lobby.cache")def test_list_waiting_participants_partially_corrupted(mock_cache, lobby_service):"""Test listing waiting participants with one valid and one corrupted entry."""room = RoomFactory(access_level=RoomAccessLevel.RESTRICTED)@@ -640,7 +640,7 @@ def test_list_waiting_participants_partially_corrupted(mock_cache, lobby_servicemock_cache.get_many.assert_called_once_with([cache_key1, cache_key2])[email protected]("core.services.lobby_service.cache")[email protected]("core.services.lobby.cache")def test_list_waiting_participants_non_waiting(mock_cache, lobby_service):"""Test listing only waiting participants (not accepted/denied)."""room = RoomFactory(access_level=RoomAccessLevel.RESTRICTED)@@ -673,7 +673,7 @@ def test_list_waiting_participants_non_waiting(mock_cache, lobby_service):assert result[0]["status"] == "waiting"[email protected]("core.services.lobby_service.LobbyService._update_participant_status")[email protected]("core.services.lobby.LobbyService._update_participant_status")def test_handle_participant_entry_allow(mock_update, lobby_service, participant_id):"""Test handling allowed participant entry."""room = RoomFactory(access_level=RoomAccessLevel.RESTRICTED)@@ -687,7 +687,7 @@ def test_handle_participant_entry_allow(mock_update, lobby_service, participant_)[email protected]("core.services.lobby_service.LobbyService._update_participant_status")[email protected]("core.services.lobby.LobbyService._update_participant_status")def test_handle_participant_entry_deny(mock_update, lobby_service, participant_id):"""Test handling denied participant entry."""room = RoomFactory(access_level=RoomAccessLevel.RESTRICTED)@@ -701,7 +701,7 @@ def test_handle_participant_entry_deny(mock_update, lobby_service, participant_i)[email protected]("core.services.lobby_service.cache")[email protected]("core.services.lobby.cache")def test_update_participant_status_not_found(mock_cache, lobby_service, participant_id):"""Test updating status for non-existent participant."""room = RoomFactory(access_level=RoomAccessLevel.RESTRICTED)@@ -720,8 +720,8 @@ def test_update_participant_status_not_found(mock_cache, lobby_service, participmock_cache.get.assert_called_once_with("mocked_cache_key")[email protected]("core.services.lobby_service.cache")[email protected]("core.services.lobby_service.LobbyParticipant.from_dict")[email protected]("core.services.lobby.cache")[email protected]("core.services.lobby.LobbyParticipant.from_dict")def test_update_participant_status_corrupted_data(mock_from_dict, mock_cache, lobby_service, participant_id):@@ -743,7 +743,7 @@ def test_update_participant_status_corrupted_data(lobby_service._get_cache_key.assert_called_once_with(room.id, participant_id)[email protected]("core.services.lobby_service.cache")[email protected]("core.services.lobby.cache")def test_update_participant_status_success(mock_cache, lobby_service, participant_id):"""Test successful participant status update."""room = RoomFactory(access_level=RoomAccessLevel.RESTRICTED)@@ -776,7 +776,7 @@ def test_update_participant_status_success(mock_cache, lobby_service, participanlobby_service._get_cache_key.assert_called_once_with(room.id, participant_id)[email protected]("core.services.lobby_service.LiveKitAPI")[email protected]("core.services.lobby.LiveKitAPI")def test_notify_participants_success(mock_livekit_api, lobby_service):"""Test successful participant notification."""room = RoomFactory(access_level=RoomAccessLevel.RESTRICTED)@@ -807,7 +807,7 @@ def test_notify_participants_success(mock_livekit_api, lobby_service):mock_api_instance.aclose.assert_called_once()[email protected]("core.services.lobby_service.LiveKitAPI")[email protected]("core.services.lobby.LiveKitAPI")def test_notify_participants_error(mock_livekit_api, lobby_service):"""Test participant notification with API error."""room = RoomFactory(access_level=RoomAccessLevel.RESTRICTED)diff --git a/src/backend/core/tests/services/test_marketing_service.py b/src/backend/core/tests/services/test_marketing.pysimilarity index 94%rename from src/backend/core/tests/services/test_marketing_service.pyrename to src/backend/core/tests/services/test_marketing.pyindex 910fbae5..6a19c70d 100644--- a/src/backend/core/tests/services/test_marketing_service.py+++ b/src/backend/core/tests/services/test_marketing.py@@ -12,7 +12,7 @@ from django.core.exceptions import ImproperlyConfiguredimport brevo_pythonimport pytest-from core.services.marketing_service import (+from core.services.marketing import (BrevoMarketingService,ContactCreationError,ContactData,@@ -144,9 +144,7 @@ def clear_marketing_cache():def test_get_marketing_service_caching(clear_marketing_cache):"""Test marketing service caching behavior."""settings.BREVO_API_KEY = "test-api-key"- settings.MARKETING_SERVICE_CLASS = (- "core.services.marketing_service.BrevoMarketingService"- )+ settings.MARKETING_SERVICE_CLASS = "core.services.marketing.BrevoMarketingService"service1 = get_marketing_service()service2 = get_marketing_service()@@ -163,14 +161,12 @@ def test_get_marketing_service_invalid_class(clear_marketing_cache):get_marketing_service()[email protected]("core.services.marketing_service.import_string")[email protected]("core.services.marketing.import_string")def test_service_instantiation_called_once(mock_import_string, clear_marketing_cache):"""Test service class is instantiated only once."""settings.BREVO_API_KEY = "test-api-key"- settings.MARKETING_SERVICE_CLASS = (- "core.services.marketing_service.BrevoMarketingService"- )+ settings.MARKETING_SERVICE_CLASS = "core.services.marketing.BrevoMarketingService"get_marketing_service.cache_clear()mock_service_cls = mock.Mock()diff --git a/src/backend/meet/settings.py b/src/backend/meet/settings.pyindex f25cf0a9..10f44c38 100755--- a/src/backend/meet/settings.py+++ b/src/backend/meet/settings.py@@ -484,7 +484,7 @@ class Base(Configuration):environ_prefix=None,)MARKETING_SERVICE_CLASS = values.Value(- "core.services.marketing_service.BrevoMarketingService",+ "core.services.marketing.BrevoMarketingService",environ_name="MARKETING_SERVICE_CLASS",environ_prefix=None,)