From c4942c5aa7de77fe309d06af9fe5e4fe505962cc Mon Sep 17 00:00:00 2001 From: xiomara Date: Thu, 6 Jun 2024 23:21:44 -0400 Subject: [PATCH 1/4] Add docstring rules to Ruff linting configuration --- Backend/ruff.toml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Backend/ruff.toml b/Backend/ruff.toml index d22ce6de..ba84bd77 100644 --- a/Backend/ruff.toml +++ b/Backend/ruff.toml @@ -13,7 +13,13 @@ extend-select = [ "C90", "D201", "D202", - "PLR" + "PLR", + "D100", + "D102", + "D103", + "D104", + "D300", + "D419", ] ignore = ["PLR0402","PLR0911"] From ee583242d512298109c2e719d0e5ead33e5efa3f Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Fri, 7 Jun 2024 20:25:38 +0200 Subject: [PATCH 2/4] docs: add main module documentation --- Backend/app/__main__.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Backend/app/__main__.py b/Backend/app/__main__.py index 0846fb59..d79d981e 100644 --- a/Backend/app/__main__.py +++ b/Backend/app/__main__.py @@ -1,3 +1,12 @@ +"""App entrypoint that + +* Handles startup and shutdown app events +* Load middlewares +* Creates the app object +* Configure Uvicorn server + +""" + from contextlib import asynccontextmanager import uvicorn From 59b88f1f4f294c1cf3916b95d186c9571af6e28e Mon Sep 17 00:00:00 2001 From: Antonio Martinez Date: Sat, 8 Jun 2024 13:21:38 +0200 Subject: [PATCH 3/4] docs: add missing package,module and method missing docs --- Backend/app/__main__.py | 11 +++++----- Backend/app/common/PropertiesManager.py | 8 +++++-- .../app/common/PropertiesMessagesManager.py | 6 ++++++ Backend/app/common/config_constants.py | 4 ++++ Backend/app/common/set_up_constants.py | 5 ++++- Backend/app/database/Database.py | 4 ++++ .../app/exceptions/base_exceptions_schema.py | 6 ++++++ Backend/app/logging/LogPropertiesManager.py | 4 ++++ Backend/app/logging/logging_constants.py | 4 ++++ Backend/app/logging/logging_schema.py | 21 +++++++++++++++++-- .../app/middleware/CheckJwtAuthMiddleware.py | 19 ++++++++++++++--- .../app/middleware/cors_middleware_config.py | 4 ++++ Backend/app/patterns/Factory.py | 4 ++++ Backend/app/patterns/Singleton.py | 5 +++++ .../genre/genre_controller.py | 4 ++++ .../spotify_electron/genre/genre_schema.py | 4 ++++ .../spotify_electron/genre/genre_service.py | 4 ++++ .../health/health_controller.py | 6 +++++- .../login/login_controller.py | 4 ++++ .../spotify_electron/login/login_schema.py | 4 ++++ .../playlist/playlist_controller.py | 4 ++++ .../playlist/playlist_repository.py | 4 ++++ .../playlist/playlist_schema.py | 4 ++++ .../playlist/playlist_service.py | 4 ++++ .../providers/playlist_collection_provider.py | 4 ++++ .../playlist_repository_validations.py | 4 ++++ .../playlist_service_validations.py | 4 ++++ .../search/search_controller.py | 4 ++++ .../spotify_electron/search/search_schema.py | 4 ++++ .../spotify_electron/search/search_service.py | 4 ++++ .../security/security_schema.py | 8 +++---- .../security/security_service.py | 12 +++++++---- .../serverless_function/song_repository.py | 7 +++++++ .../aws/serverless_function/song_schema.py | 4 ++++ .../song_serverless_function_api.py | 4 ++++ .../aws/serverless_function/song_service.py | 6 +++++- .../song_service_validations.py | 4 ++++ .../song/base_song_repository.py | 5 +++++ .../spotify_electron/song/base_song_schema.py | 12 ++++++++--- .../song/base_song_service.py | 7 +++++++ .../song/blob/song_repository.py | 7 +++++++ .../spotify_electron/song/blob/song_schema.py | 5 +++++ .../song/blob/song_service.py | 4 ++++ .../validations/song_service_validations.py | 4 ++++ .../providers/song_collection_provider.py | 4 ++++ .../song/providers/song_service_provider.py | 9 ++++++++ .../spotify_electron/song/song_controller.py | 5 +++++ .../song/song_service_constants.py | 4 ++++ .../base_song_repository_validations.py | 4 ++++ .../base_song_service_validations.py | 4 ++++ .../user/artist/artist_controller.py | 4 ++++ .../user/artist/artist_repository.py | 4 ++++ .../user/artist/artist_schema.py | 4 ++++ .../user/artist/artist_service.py | 12 +++++++++++ .../artist_repository_validations.py | 4 ++++ .../user/base_user_repository.py | 5 +++++ .../user/base_user_service.py | 5 +++++ .../providers/user_collection_provider.py | 4 ++++ .../user/providers/user_service_provider.py | 4 ++++ .../user/user/user_repository.py | 4 ++++ .../spotify_electron/user/user/user_schema.py | 4 ++++ .../user/user/user_service.py | 4 ++++ .../spotify_electron/user/user_controller.py | 16 +++++--------- .../base_users_repository_validations.py | 4 ++++ .../validations/user_service_validations.py | 4 ++++ .../audio_management_utils.py | 4 ++++ .../spotify_electron/utils/date/date_utils.py | 12 ++++++++++- .../json_converter/json_converter_utils.py | 4 ++++ .../utils/validations/validation_utils.py | 4 ++++ Backend/docker/build_and_up_dev.sh | 0 Backend/tests/test__properties_manager.py | 2 -- 71 files changed, 358 insertions(+), 40 deletions(-) rename Backend/app/spotify_electron/song/aws/serverless_function/{ => validations}/song_service_validations.py (97%) mode change 100644 => 100755 Backend/docker/build_and_up_dev.sh diff --git a/Backend/app/__main__.py b/Backend/app/__main__.py index d79d981e..1196e9d5 100644 --- a/Backend/app/__main__.py +++ b/Backend/app/__main__.py @@ -1,9 +1,10 @@ -"""App entrypoint that +""" +FastAPI App entrypoint -* Handles startup and shutdown app events -* Load middlewares -* Creates the app object -* Configure Uvicorn server +- Handles startup and shutdown app events +- Load middlewares +- Creates the app object +- Configure Uvicorn server """ diff --git a/Backend/app/common/PropertiesManager.py b/Backend/app/common/PropertiesManager.py index ea5c4274..fc043540 100644 --- a/Backend/app/common/PropertiesManager.py +++ b/Backend/app/common/PropertiesManager.py @@ -1,3 +1,9 @@ +""" +Manages APP global state variables and manages initialization of enviroment variables and .ini files + +Declares PropertiesManager global object to be accessed from across the app +""" + import configparser import os @@ -14,7 +20,6 @@ ARCHITECTURE_ENV_NAME, DEFAULT_ARCHITECTURE, DEV, - DISTRIBUTION_ID_ENV_NAME, ENV_VALUE_ENV_NAME, MONGO_URI_ENV_NAME, PROD, @@ -41,7 +46,6 @@ def __init__(self) -> None: self.env_variables = [ MONGO_URI_ENV_NAME, SECRET_KEY_SIGN_ENV_NAME, - DISTRIBUTION_ID_ENV_NAME, SERVERLESS_FUNCTION_URL_ENV_NAME, ENV_VALUE_ENV_NAME, ] diff --git a/Backend/app/common/PropertiesMessagesManager.py b/Backend/app/common/PropertiesMessagesManager.py index 351280c9..cac280f8 100644 --- a/Backend/app/common/PropertiesMessagesManager.py +++ b/Backend/app/common/PropertiesMessagesManager.py @@ -1,3 +1,9 @@ +""" +Manages APP global messages, storing and making them accesible across the app + +Declares _PropertiesMessagesManager global object to be accessed from across the app +""" + import configparser import os import re diff --git a/Backend/app/common/config_constants.py b/Backend/app/common/config_constants.py index 1cd5529d..a2e20e0b 100644 --- a/Backend/app/common/config_constants.py +++ b/Backend/app/common/config_constants.py @@ -1,3 +1,7 @@ +""" +Constants for APP configuration +""" + RESOURCES_FOLDER = "resources" CONFIG_FILENAME = "config.ini" APP_CONFIG_SECTION = "app" diff --git a/Backend/app/common/set_up_constants.py b/Backend/app/common/set_up_constants.py index e285f026..2fe78e42 100644 --- a/Backend/app/common/set_up_constants.py +++ b/Backend/app/common/set_up_constants.py @@ -1,3 +1,7 @@ +""" +Constants for APP setup such as Architectures, launch mode and path for enviroment variables +""" + ARCH_STREAMING_SERVERLESS_FUNCTION = "STREAMING_SERVERLESS_FUNCTION" ARCH_BLOB = "BLOB" @@ -10,6 +14,5 @@ SECRET_KEY_SIGN_ENV_NAME = "SECRET_KEY_SIGN" MONGO_URI_ENV_NAME = "MONGO_URI" -DISTRIBUTION_ID_ENV_NAME = "DISTRIBUTION_ID" SERVERLESS_FUNCTION_URL_ENV_NAME = "SERVERLESS_FUNCTION_URL" ENV_VALUE_ENV_NAME = "ENV_VALUE" diff --git a/Backend/app/database/Database.py b/Backend/app/database/Database.py index 6b3bf2b9..44d04a29 100644 --- a/Backend/app/database/Database.py +++ b/Backend/app/database/Database.py @@ -1,3 +1,7 @@ +""" +Manages the unique database connection across the app and provides the modules with the collections needed for persist data. +""" + import sys from enum import StrEnum from typing import Any diff --git a/Backend/app/exceptions/base_exceptions_schema.py b/Backend/app/exceptions/base_exceptions_schema.py index ab946040..3c634b76 100644 --- a/Backend/app/exceptions/base_exceptions_schema.py +++ b/Backend/app/exceptions/base_exceptions_schema.py @@ -1,3 +1,7 @@ +""" +Base common exceptions for the whole app +""" + from app.logging.logging_constants import LOGGING_EXCEPTION from app.logging.logging_schema import SpotifyElectronLogger @@ -5,6 +9,8 @@ class SpotifyElectronException(Exception): + """Base app exception, all exceptions must inherit from it""" + def __init__(self, message): super().__init__(message) diff --git a/Backend/app/logging/LogPropertiesManager.py b/Backend/app/logging/LogPropertiesManager.py index dc1710c3..b23e6ebd 100644 --- a/Backend/app/logging/LogPropertiesManager.py +++ b/Backend/app/logging/LogPropertiesManager.py @@ -1,3 +1,7 @@ +""" +Loads and manages logging configurations +""" + import configparser import os diff --git a/Backend/app/logging/logging_constants.py b/Backend/app/logging/logging_constants.py index fdab0346..0ce5eb80 100644 --- a/Backend/app/logging/logging_constants.py +++ b/Backend/app/logging/logging_constants.py @@ -1,3 +1,7 @@ +""" +Logging constants +""" + # Log Levels DEBUG = "DEBUG" INFO = "INFO" diff --git a/Backend/app/logging/logging_schema.py b/Backend/app/logging/logging_schema.py index 7f3076fc..4f51a71d 100644 --- a/Backend/app/logging/logging_schema.py +++ b/Backend/app/logging/logging_schema.py @@ -1,3 +1,7 @@ +""" +Logging and Format schemas +""" + import logging import logging.handlers import sys @@ -34,7 +38,15 @@ class SpotifyElectronFormatter(logging.Formatter): ), } - def format(self, record): + def format(self, record: logging.LogRecord) -> str: + """Format log output with the custom formatter structure + + Args: + record (LogRecord): the output log record + + Returns: + str: the result of formating the log record with the custom formatter + """ log_format = self.FORMATS.get( record.levelno, "%(asctime)s - %(name)s - %(levelname)s - %(message)s" ) @@ -106,5 +118,10 @@ def _get_log_level(self) -> int: else: return mapped_log_level - def getLogger(self): + def getLogger(self) -> logging.Logger: + """Returns the global logger + + Returns: + logging.Logger: the global logger + """ return self.logger diff --git a/Backend/app/middleware/CheckJwtAuthMiddleware.py b/Backend/app/middleware/CheckJwtAuthMiddleware.py index 8f0c7024..3cf3532b 100644 --- a/Backend/app/middleware/CheckJwtAuthMiddleware.py +++ b/Backend/app/middleware/CheckJwtAuthMiddleware.py @@ -1,3 +1,5 @@ +"""Middleware for authenticate incoming HTTP Requests using JWT Token""" + from fastapi import Request, Response from starlette.middleware.base import BaseHTTPMiddleware from starlette.status import HTTP_401_UNAUTHORIZED @@ -62,6 +64,15 @@ def bypass_request(self, request: Request) -> bool: return False async def dispatch(self, request: Request, call_next): + """Manages the incoming HTTP request and decides wheter or not it has to be blocked + + Args: + request (Request): the incoming request + call_next (_type_): the method to call next + + Returns: + _type_: the call next output if request was not blocked + """ try: if self.bypass_request(request): check_jwt_auth_middleware_logger.debug( @@ -77,14 +88,16 @@ async def dispatch(self, request: Request, call_next): status_code=HTTP_401_UNAUTHORIZED, ) - async def _handle_jwt_validation(self, jwt, request, call_next) -> Response: + async def _handle_jwt_validation( + self, jwt: str, request: Request, call_next + ) -> Response: """Handles JWT validation, sends HTTP_401_UNAUTHORIZED if jwt is not valid or\ continues the workflow Args: ---- - jwt (_type_): the jwt token - request (_type_): the incoming request + jwt (str): the jwt token + request (Request): the incoming request call_next (_type_): the method for continuing the workflow Returns: diff --git a/Backend/app/middleware/cors_middleware_config.py b/Backend/app/middleware/cors_middleware_config.py index a82120b0..bbe297a5 100644 --- a/Backend/app/middleware/cors_middleware_config.py +++ b/Backend/app/middleware/cors_middleware_config.py @@ -1,3 +1,7 @@ +""" +CORS Middleware configurations +""" + allowed_origins = [ "http://localhost/", "http://localhost:1212", diff --git a/Backend/app/patterns/Factory.py b/Backend/app/patterns/Factory.py index 09754c3c..d45943bb 100644 --- a/Backend/app/patterns/Factory.py +++ b/Backend/app/patterns/Factory.py @@ -1,3 +1,7 @@ +""" +Song Service Factory Pattern +""" + from abc import ABC, abstractmethod diff --git a/Backend/app/patterns/Singleton.py b/Backend/app/patterns/Singleton.py index 42d31c0c..af88d51e 100644 --- a/Backend/app/patterns/Singleton.py +++ b/Backend/app/patterns/Singleton.py @@ -1,3 +1,8 @@ +""" +Singleton Pattern +""" + + class Singleton(type): """The Singleton class can be implemented in different ways in Python. Some possible methods include: base class, decorator, metaclass. We will use the diff --git a/Backend/app/spotify_electron/genre/genre_controller.py b/Backend/app/spotify_electron/genre/genre_controller.py index 2beac2fe..9f49ba89 100644 --- a/Backend/app/spotify_electron/genre/genre_controller.py +++ b/Backend/app/spotify_electron/genre/genre_controller.py @@ -1,3 +1,7 @@ +""" +Genre controller for handling incoming HTTP Requests +""" + from fastapi import APIRouter from fastapi.responses import Response from starlette.status import HTTP_200_OK, HTTP_500_INTERNAL_SERVER_ERROR diff --git a/Backend/app/spotify_electron/genre/genre_schema.py b/Backend/app/spotify_electron/genre/genre_schema.py index 1533188c..dc0c7732 100644 --- a/Backend/app/spotify_electron/genre/genre_schema.py +++ b/Backend/app/spotify_electron/genre/genre_schema.py @@ -1,3 +1,7 @@ +""" +Genre schema for domain model +""" + from enum import StrEnum from app.exceptions.base_exceptions_schema import SpotifyElectronException diff --git a/Backend/app/spotify_electron/genre/genre_service.py b/Backend/app/spotify_electron/genre/genre_service.py index e21ef85a..c56d5d39 100644 --- a/Backend/app/spotify_electron/genre/genre_service.py +++ b/Backend/app/spotify_electron/genre/genre_service.py @@ -1,3 +1,7 @@ +""" +Genre service for handling business logic +""" + import json from app.logging.logging_constants import LOGGING_GENRE_SERVICE diff --git a/Backend/app/spotify_electron/health/health_controller.py b/Backend/app/spotify_electron/health/health_controller.py index f05f382f..3d98d9db 100644 --- a/Backend/app/spotify_electron/health/health_controller.py +++ b/Backend/app/spotify_electron/health/health_controller.py @@ -1,3 +1,7 @@ +""" +Health controller for handling incoming HTTP Requests +""" + from fastapi import APIRouter from fastapi.responses import Response from starlette.status import HTTP_200_OK @@ -7,7 +11,7 @@ @router.get("/", summary="Health Check Endpoint") def get_health(): - """Health endpoint allows us to determine if the app has launched correctly + """Validates if the app has launched correctly Returns ------- diff --git a/Backend/app/spotify_electron/login/login_controller.py b/Backend/app/spotify_electron/login/login_controller.py index d6eec1e2..6da9d7b2 100644 --- a/Backend/app/spotify_electron/login/login_controller.py +++ b/Backend/app/spotify_electron/login/login_controller.py @@ -1,3 +1,7 @@ +""" +Login controller for handling incoming HTTP Requests +""" + from typing import Annotated from fastapi import APIRouter, Depends diff --git a/Backend/app/spotify_electron/login/login_schema.py b/Backend/app/spotify_electron/login/login_schema.py index 6f8b057c..3218a365 100644 --- a/Backend/app/spotify_electron/login/login_schema.py +++ b/Backend/app/spotify_electron/login/login_schema.py @@ -1,3 +1,7 @@ +""" +Login schema for domain model +""" + from app.exceptions.base_exceptions_schema import SpotifyElectronException diff --git a/Backend/app/spotify_electron/playlist/playlist_controller.py b/Backend/app/spotify_electron/playlist/playlist_controller.py index 401b87dc..668861ac 100644 --- a/Backend/app/spotify_electron/playlist/playlist_controller.py +++ b/Backend/app/spotify_electron/playlist/playlist_controller.py @@ -1,3 +1,7 @@ +""" +Playlist controller for handling incoming HTTP Requests +""" + from typing import Annotated from fastapi import APIRouter, Body, Header diff --git a/Backend/app/spotify_electron/playlist/playlist_repository.py b/Backend/app/spotify_electron/playlist/playlist_repository.py index 7bea23e5..4aae690c 100644 --- a/Backend/app/spotify_electron/playlist/playlist_repository.py +++ b/Backend/app/spotify_electron/playlist/playlist_repository.py @@ -1,3 +1,7 @@ +""" +Playlist repository for managing persisted data +""" + from app.logging.logging_constants import LOGGING_PLAYLIST_REPOSITORY from app.logging.logging_schema import SpotifyElectronLogger from app.spotify_electron.playlist.playlist_schema import ( diff --git a/Backend/app/spotify_electron/playlist/playlist_schema.py b/Backend/app/spotify_electron/playlist/playlist_schema.py index ef2d7a91..d5a898a0 100644 --- a/Backend/app/spotify_electron/playlist/playlist_schema.py +++ b/Backend/app/spotify_electron/playlist/playlist_schema.py @@ -1,3 +1,7 @@ +""" +Playlist schema for domain model +""" + from dataclasses import dataclass from app.exceptions.base_exceptions_schema import SpotifyElectronException diff --git a/Backend/app/spotify_electron/playlist/playlist_service.py b/Backend/app/spotify_electron/playlist/playlist_service.py index c7e9ffae..60d29c68 100644 --- a/Backend/app/spotify_electron/playlist/playlist_service.py +++ b/Backend/app/spotify_electron/playlist/playlist_service.py @@ -1,3 +1,7 @@ +""" +Playlist service for handling business logic +""" + import app.spotify_electron.playlist.playlist_repository as playlist_repository import app.spotify_electron.security.security_service as security_service import app.spotify_electron.user.base_user_service as base_user_service diff --git a/Backend/app/spotify_electron/playlist/providers/playlist_collection_provider.py b/Backend/app/spotify_electron/playlist/providers/playlist_collection_provider.py index a0b27b4f..aa3d9704 100644 --- a/Backend/app/spotify_electron/playlist/providers/playlist_collection_provider.py +++ b/Backend/app/spotify_electron/playlist/providers/playlist_collection_provider.py @@ -1,3 +1,7 @@ +""" +Provider class for supplying playlist collection connection with database +""" + from pymongo.collection import Collection from app.database.Database import Database, DatabaseCollection diff --git a/Backend/app/spotify_electron/playlist/validations/playlist_repository_validations.py b/Backend/app/spotify_electron/playlist/validations/playlist_repository_validations.py index 0177b538..9719669b 100644 --- a/Backend/app/spotify_electron/playlist/validations/playlist_repository_validations.py +++ b/Backend/app/spotify_electron/playlist/validations/playlist_repository_validations.py @@ -1,3 +1,7 @@ +""" +Validations for Playlist repository +""" + from pymongo.results import DeleteResult, InsertOneResult, UpdateResult from app.spotify_electron.playlist.playlist_schema import ( diff --git a/Backend/app/spotify_electron/playlist/validations/playlist_service_validations.py b/Backend/app/spotify_electron/playlist/validations/playlist_service_validations.py index 7aba7b64..f77a1a78 100644 --- a/Backend/app/spotify_electron/playlist/validations/playlist_service_validations.py +++ b/Backend/app/spotify_electron/playlist/validations/playlist_service_validations.py @@ -1,3 +1,7 @@ +""" +Validations for Playlist service +""" + from app.exceptions.base_exceptions_schema import BadParameterException from app.spotify_electron.playlist.playlist_repository import check_playlist_exists from app.spotify_electron.playlist.playlist_schema import ( diff --git a/Backend/app/spotify_electron/search/search_controller.py b/Backend/app/spotify_electron/search/search_controller.py index 66fae55e..f8d8980d 100644 --- a/Backend/app/spotify_electron/search/search_controller.py +++ b/Backend/app/spotify_electron/search/search_controller.py @@ -1,3 +1,7 @@ +""" +Search controller for handling incoming HTTP Requests +""" + from fastapi import APIRouter from fastapi.responses import Response from starlette.status import ( diff --git a/Backend/app/spotify_electron/search/search_schema.py b/Backend/app/spotify_electron/search/search_schema.py index a3c1e923..3e45eccf 100644 --- a/Backend/app/spotify_electron/search/search_schema.py +++ b/Backend/app/spotify_electron/search/search_schema.py @@ -1,3 +1,7 @@ +""" +Search schema for domain model +""" + from dataclasses import dataclass from app.exceptions.base_exceptions_schema import SpotifyElectronException diff --git a/Backend/app/spotify_electron/search/search_service.py b/Backend/app/spotify_electron/search/search_service.py index 6d901b01..71233d2f 100644 --- a/Backend/app/spotify_electron/search/search_service.py +++ b/Backend/app/spotify_electron/search/search_service.py @@ -1,3 +1,7 @@ +""" +Search service for handling business logic +""" + import app.spotify_electron.playlist.playlist_service as playlist_service import app.spotify_electron.song.base_song_service as base_song_service import app.spotify_electron.user.artist.artist_service as artist_service diff --git a/Backend/app/spotify_electron/security/security_schema.py b/Backend/app/spotify_electron/security/security_schema.py index a475df46..03ebccc2 100644 --- a/Backend/app/spotify_electron/security/security_schema.py +++ b/Backend/app/spotify_electron/security/security_schema.py @@ -1,4 +1,7 @@ -import json +""" +Security schema for domain model +""" + from dataclasses import dataclass from app.exceptions.base_exceptions_schema import SpotifyElectronException @@ -13,9 +16,6 @@ class TokenData: role: UserType token_type: str - def get_json(self) -> str: - return json.dumps(self.__dict__) - class BadJWTTokenProvidedException(SpotifyElectronException): """Exception for bad JWT Token provided""" diff --git a/Backend/app/spotify_electron/security/security_service.py b/Backend/app/spotify_electron/security/security_service.py index 7558f994..1c5c6dd6 100644 --- a/Backend/app/spotify_electron/security/security_service.py +++ b/Backend/app/spotify_electron/security/security_service.py @@ -1,3 +1,7 @@ +""" +Security service for handling business logic +""" + from datetime import UTC, datetime, timedelta, timezone from typing import Annotated, Any @@ -8,7 +12,7 @@ import app.spotify_electron.user.base_user_service as base_user_service from app.common.PropertiesManager import PropertiesManager -from app.common.set_up_constants import DISTRIBUTION_ID_ENV_NAME +from app.common.set_up_constants import SECRET_KEY_SIGN_ENV_NAME from app.exceptions.base_exceptions_schema import BadParameterException from app.logging.logging_constants import LOGGING_SECURITY_SERVICE from app.logging.logging_schema import SpotifyElectronLogger @@ -70,7 +74,7 @@ def create_access_token(data: dict, expires_delta: timedelta | None = None) -> s to_encode.update({"exp": expire}) encoded_jwt = jwt.encode( to_encode, - getattr(PropertiesManager, DISTRIBUTION_ID_ENV_NAME), + getattr(PropertiesManager, SECRET_KEY_SIGN_ENV_NAME), algorithm=ALGORITHM, ) except Exception as exception: @@ -102,7 +106,7 @@ def get_jwt_token_data( try: payload = jwt.decode( token, # type: ignore - getattr(PropertiesManager, DISTRIBUTION_ID_ENV_NAME), + getattr(PropertiesManager, SECRET_KEY_SIGN_ENV_NAME), algorithms=[ALGORITHM], ) username = payload.get("access_token") @@ -296,7 +300,7 @@ def validate_jwt(token: str) -> None: """ try: decoded_token = jwt.decode( - token, getattr(PropertiesManager, DISTRIBUTION_ID_ENV_NAME), ALGORITHM + token, getattr(PropertiesManager, SECRET_KEY_SIGN_ENV_NAME), ALGORITHM ) validate_token_is_expired(decoded_token) diff --git a/Backend/app/spotify_electron/song/aws/serverless_function/song_repository.py b/Backend/app/spotify_electron/song/aws/serverless_function/song_repository.py index 1bcb3f4d..e3b9ba05 100644 --- a/Backend/app/spotify_electron/song/aws/serverless_function/song_repository.py +++ b/Backend/app/spotify_electron/song/aws/serverless_function/song_repository.py @@ -1,3 +1,10 @@ +""" +Song repository for managing persisted data + +Song metadata is stored in database and song files are managed by AWS S3 instances +When the song file is not needed, and only the metadata is required use base song services +""" + import app.spotify_electron.song.providers.song_collection_provider as song_collection_provider from app.logging.logging_constants import ( LOGGING_SONG_AWS_SERVERLESS_FUNCTION_REPOSITORY, diff --git a/Backend/app/spotify_electron/song/aws/serverless_function/song_schema.py b/Backend/app/spotify_electron/song/aws/serverless_function/song_schema.py index 8233d165..b65a86dc 100644 --- a/Backend/app/spotify_electron/song/aws/serverless_function/song_schema.py +++ b/Backend/app/spotify_electron/song/aws/serverless_function/song_schema.py @@ -1,3 +1,7 @@ +""" +Song schema for domain model +""" + from dataclasses import dataclass from app.exceptions.base_exceptions_schema import SpotifyElectronException diff --git a/Backend/app/spotify_electron/song/aws/serverless_function/song_serverless_function_api.py b/Backend/app/spotify_electron/song/aws/serverless_function/song_serverless_function_api.py index 7de8b934..5b38ecea 100644 --- a/Backend/app/spotify_electron/song/aws/serverless_function/song_serverless_function_api.py +++ b/Backend/app/spotify_electron/song/aws/serverless_function/song_serverless_function_api.py @@ -1,3 +1,7 @@ +""" +API to comunicate with AWS Serverless Function that handles song files in Cloud +""" + from requests import Response, delete, get, post from app.common.PropertiesManager import PropertiesManager diff --git a/Backend/app/spotify_electron/song/aws/serverless_function/song_service.py b/Backend/app/spotify_electron/song/aws/serverless_function/song_service.py index f22743d5..a8028362 100644 --- a/Backend/app/spotify_electron/song/aws/serverless_function/song_service.py +++ b/Backend/app/spotify_electron/song/aws/serverless_function/song_service.py @@ -1,3 +1,7 @@ +""" +Song service for handling business logic +""" + import app.spotify_electron.song.aws.serverless_function.song_repository as song_repository import app.spotify_electron.song.aws.serverless_function.song_serverless_function_api as song_serverless_function_api import app.spotify_electron.song.base_song_repository as base_song_repository @@ -17,7 +21,7 @@ SongGetUrlStreamingException, get_song_dto_from_dao, ) -from app.spotify_electron.song.aws.serverless_function.song_service_validations import ( +from app.spotify_electron.song.aws.serverless_function.validations.song_service_validations import ( validate_get_song_url_streaming_response, validate_song_creating_streaming_response, validate_song_deleting_streaming_response, diff --git a/Backend/app/spotify_electron/song/aws/serverless_function/song_service_validations.py b/Backend/app/spotify_electron/song/aws/serverless_function/validations/song_service_validations.py similarity index 97% rename from Backend/app/spotify_electron/song/aws/serverless_function/song_service_validations.py rename to Backend/app/spotify_electron/song/aws/serverless_function/validations/song_service_validations.py index ef62ea67..5349d6ea 100644 --- a/Backend/app/spotify_electron/song/aws/serverless_function/song_service_validations.py +++ b/Backend/app/spotify_electron/song/aws/serverless_function/validations/song_service_validations.py @@ -1,3 +1,7 @@ +""" +Validations for AWS Serverless Function Song service +""" + from requests import Response from starlette.status import HTTP_200_OK, HTTP_201_CREATED, HTTP_202_ACCEPTED diff --git a/Backend/app/spotify_electron/song/base_song_repository.py b/Backend/app/spotify_electron/song/base_song_repository.py index cfde28db..1fd30b22 100644 --- a/Backend/app/spotify_electron/song/base_song_repository.py +++ b/Backend/app/spotify_electron/song/base_song_repository.py @@ -1,3 +1,8 @@ +""" +Song repository for managing common persisted data regardless of the current architecture. +The repository will only handle Song metadata +""" + import app.spotify_electron.song.providers.song_collection_provider as song_collection_provider from app.logging.logging_constants import ( LOGGING_BASE_SONG_REPOSITORY, diff --git a/Backend/app/spotify_electron/song/base_song_schema.py b/Backend/app/spotify_electron/song/base_song_schema.py index cf4c0cf8..6bfa23ef 100644 --- a/Backend/app/spotify_electron/song/base_song_schema.py +++ b/Backend/app/spotify_electron/song/base_song_schema.py @@ -1,3 +1,9 @@ +""" +Base Song schema. +It contains Base DAO/DTO objects both for Metadata and Song containing +the song resource. +""" + from dataclasses import dataclass from app.exceptions.base_exceptions_schema import SpotifyElectronException @@ -6,7 +12,7 @@ @dataclass class BaseSongDAO: - """Class to represent song data in the persistence layer""" + """Base Class to represent song data in the persistence layer""" name: str photo: str @@ -18,7 +24,7 @@ class BaseSongDAO: @dataclass class BaseSongDTO: - """Class to represent song data in the endpoints transfering layer""" + """Base Class to represent song data in the endpoints transfering layer""" name: str photo: str @@ -29,7 +35,7 @@ class BaseSongDTO: @dataclass -class SongMetadataDAO(BaseSongDTO): +class SongMetadataDAO(BaseSongDAO): """Class to represent Song metadata in the persistence transfering layer""" diff --git a/Backend/app/spotify_electron/song/base_song_service.py b/Backend/app/spotify_electron/song/base_song_service.py index 71add33d..46977841 100644 --- a/Backend/app/spotify_electron/song/base_song_service.py +++ b/Backend/app/spotify_electron/song/base_song_service.py @@ -1,3 +1,10 @@ +""" +Base Song service for handling bussiness logic + +Handles common methods between all song architectures +Redirects to the specific architecture service in case the method is not common +""" + import app.spotify_electron.song.base_song_repository as base_song_repository import app.spotify_electron.user.base_user_service as base_user_service from app.logging.logging_constants import LOGGING_BASE_SONG_SERVICE diff --git a/Backend/app/spotify_electron/song/blob/song_repository.py b/Backend/app/spotify_electron/song/blob/song_repository.py index 64b10fdd..3c2bbfbf 100644 --- a/Backend/app/spotify_electron/song/blob/song_repository.py +++ b/Backend/app/spotify_electron/song/blob/song_repository.py @@ -1,3 +1,10 @@ +""" +Song repository for managing persisted data. These are stored using GridFS, a MongoDB fylesystem for storing BLOB files and its metadata.S See https://www.mongodb.com/docs/manual/core/gridfs/ + +Song files are stored as BLOBs in a separated collection from the metadata +When the song file is not needed, and only the metadata is required use base song services +""" + import app.spotify_electron.song.providers.song_collection_provider as song_collection_provider from app.logging.logging_constants import LOGGING_SONG_BLOB_REPOSITORY from app.logging.logging_schema import SpotifyElectronLogger diff --git a/Backend/app/spotify_electron/song/blob/song_schema.py b/Backend/app/spotify_electron/song/blob/song_schema.py index 3c16fd16..595a4a82 100644 --- a/Backend/app/spotify_electron/song/blob/song_schema.py +++ b/Backend/app/spotify_electron/song/blob/song_schema.py @@ -1,3 +1,7 @@ +""" +Song schema for domain model +""" + from dataclasses import dataclass from gridfs.grid_file import GridOut @@ -16,6 +20,7 @@ class SongDAO(BaseSongDAO): """Class to represent song data in the persistence layer""" file: str + """Base 64 encoded bytes of the song file""" @dataclass diff --git a/Backend/app/spotify_electron/song/blob/song_service.py b/Backend/app/spotify_electron/song/blob/song_service.py index 348129a9..23d465bb 100644 --- a/Backend/app/spotify_electron/song/blob/song_service.py +++ b/Backend/app/spotify_electron/song/blob/song_service.py @@ -1,3 +1,7 @@ +""" +Song service for handling business logic +""" + import app.spotify_electron.song.base_song_repository as base_song_repository import app.spotify_electron.song.blob.song_repository as song_repository import app.spotify_electron.user.artist.artist_service as artist_service diff --git a/Backend/app/spotify_electron/song/blob/validations/song_service_validations.py b/Backend/app/spotify_electron/song/blob/validations/song_service_validations.py index 44291d3a..e660c627 100644 --- a/Backend/app/spotify_electron/song/blob/validations/song_service_validations.py +++ b/Backend/app/spotify_electron/song/blob/validations/song_service_validations.py @@ -1,3 +1,7 @@ +""" +Validations for Blob Song service +""" + from app.exceptions.base_exceptions_schema import BadParameterException from app.spotify_electron.song.base_song_schema import SongCreateException from app.spotify_electron.utils.validations.validation_utils import validate_parameter diff --git a/Backend/app/spotify_electron/song/providers/song_collection_provider.py b/Backend/app/spotify_electron/song/providers/song_collection_provider.py index 14537742..a85c65cc 100644 --- a/Backend/app/spotify_electron/song/providers/song_collection_provider.py +++ b/Backend/app/spotify_electron/song/providers/song_collection_provider.py @@ -1,3 +1,7 @@ +""" +Provider class for supplying song collection connection with database depending on the architecture on song selected +""" + from gridfs import GridFS from pymongo.collection import Collection diff --git a/Backend/app/spotify_electron/song/providers/song_service_provider.py b/Backend/app/spotify_electron/song/providers/song_service_provider.py index 546fa1b5..8d2c1120 100644 --- a/Backend/app/spotify_electron/song/providers/song_service_provider.py +++ b/Backend/app/spotify_electron/song/providers/song_service_provider.py @@ -1,3 +1,7 @@ +""" +Provider class for supplying service depending on song architecture selected +""" + import importlib from types import ModuleType @@ -29,6 +33,11 @@ def __init__(self) -> None: super().__init__() def create_song_service(self) -> ModuleType: + """Creates the song service depending on the song architecture selected + + Returns: + ModuleType: the song module based on current architecture + """ return self._get_song_service() def _get_song_service(self) -> ModuleType: diff --git a/Backend/app/spotify_electron/song/song_controller.py b/Backend/app/spotify_electron/song/song_controller.py index b09a92dc..df29a9de 100644 --- a/Backend/app/spotify_electron/song/song_controller.py +++ b/Backend/app/spotify_electron/song/song_controller.py @@ -1,3 +1,8 @@ +""" +Song controller for handling incoming HTTP Requests +It uses the base_song_service for handling logic for different song architectures +""" + from typing import Annotated from fastapi import APIRouter, Header, UploadFile diff --git a/Backend/app/spotify_electron/song/song_service_constants.py b/Backend/app/spotify_electron/song/song_service_constants.py index ee9b7260..d885c2e0 100644 --- a/Backend/app/spotify_electron/song/song_service_constants.py +++ b/Backend/app/spotify_electron/song/song_service_constants.py @@ -1,3 +1,7 @@ +""" +Constants for Song services +""" + MODULE_PREFIX_NAME = "app.spotify_electron.song." SONG_SERVICE_STREAMING_AWS_SERVERLESS_FUNCTION_SERVICE_MODULE_NAME = ( "aws.serverless_function.song_service" diff --git a/Backend/app/spotify_electron/song/validations/base_song_repository_validations.py b/Backend/app/spotify_electron/song/validations/base_song_repository_validations.py index f26de0c3..8fbce6ba 100644 --- a/Backend/app/spotify_electron/song/validations/base_song_repository_validations.py +++ b/Backend/app/spotify_electron/song/validations/base_song_repository_validations.py @@ -1,3 +1,7 @@ +""" +Common validations for all Song services, regardless of the current architecture +""" + from pymongo.results import DeleteResult, InsertOneResult from app.spotify_electron.song.base_song_schema import ( diff --git a/Backend/app/spotify_electron/song/validations/base_song_service_validations.py b/Backend/app/spotify_electron/song/validations/base_song_service_validations.py index b56eee7a..09245b21 100644 --- a/Backend/app/spotify_electron/song/validations/base_song_service_validations.py +++ b/Backend/app/spotify_electron/song/validations/base_song_service_validations.py @@ -1,3 +1,7 @@ +""" +Common validations for all Song respositories, regardless of the current architecture +""" + from app.exceptions.base_exceptions_schema import BadParameterException from app.spotify_electron.song.base_song_repository import check_song_exists from app.spotify_electron.song.base_song_schema import ( diff --git a/Backend/app/spotify_electron/user/artist/artist_controller.py b/Backend/app/spotify_electron/user/artist/artist_controller.py index 5a8b6301..397a6f11 100644 --- a/Backend/app/spotify_electron/user/artist/artist_controller.py +++ b/Backend/app/spotify_electron/user/artist/artist_controller.py @@ -1,3 +1,7 @@ +""" +Artist controller for handling incoming HTTP Requests +""" + import json from fastapi import APIRouter diff --git a/Backend/app/spotify_electron/user/artist/artist_repository.py b/Backend/app/spotify_electron/user/artist/artist_repository.py index cbb4379f..ecb5f88f 100644 --- a/Backend/app/spotify_electron/user/artist/artist_repository.py +++ b/Backend/app/spotify_electron/user/artist/artist_repository.py @@ -1,3 +1,7 @@ +""" +Artist repository for managing persisted data +""" + import app.spotify_electron.user.providers.user_collection_provider as user_collection_provider from app.logging.logging_constants import LOGGING_ARTIST_REPOSITORY from app.logging.logging_schema import SpotifyElectronLogger diff --git a/Backend/app/spotify_electron/user/artist/artist_schema.py b/Backend/app/spotify_electron/user/artist/artist_schema.py index 4423d2d4..782562c3 100644 --- a/Backend/app/spotify_electron/user/artist/artist_schema.py +++ b/Backend/app/spotify_electron/user/artist/artist_schema.py @@ -1,3 +1,7 @@ +""" +Artist schema for User domain model +""" + from dataclasses import dataclass from app.spotify_electron.user.user.user_schema import UserDAO, UserDTO diff --git a/Backend/app/spotify_electron/user/artist/artist_service.py b/Backend/app/spotify_electron/user/artist/artist_service.py index 56e45a0f..0e8f2e4e 100644 --- a/Backend/app/spotify_electron/user/artist/artist_service.py +++ b/Backend/app/spotify_electron/user/artist/artist_service.py @@ -1,3 +1,7 @@ +""" +Artist service for handling business logic +""" + import app.spotify_electron.security.security_service as security_service import app.spotify_electron.song.base_song_service as base_song_service import app.spotify_electron.user.artist.artist_repository as artist_repository @@ -213,6 +217,14 @@ def create_artist(user_name: str, photo: str, password: str) -> None: def get_all_artists() -> list[ArtistDTO]: + """Get all artists + + Raises: + UserServiceException: unexpected error getting all artists + + Returns: + list[ArtistDTO]: the list of all artists + """ try: artists_dao = artist_repository.get_all_artists() artists_dto = [ diff --git a/Backend/app/spotify_electron/user/artist/validations/artist_repository_validations.py b/Backend/app/spotify_electron/user/artist/validations/artist_repository_validations.py index 945435ef..136a2060 100644 --- a/Backend/app/spotify_electron/user/artist/validations/artist_repository_validations.py +++ b/Backend/app/spotify_electron/user/artist/validations/artist_repository_validations.py @@ -1,3 +1,7 @@ +""" +Validations for artist repository +""" + from app.spotify_electron.security.security_schema import UserUnauthorizedException from app.spotify_electron.user.artist.artist_service import does_artist_exists diff --git a/Backend/app/spotify_electron/user/base_user_repository.py b/Backend/app/spotify_electron/user/base_user_repository.py index 6bd02917..992497d2 100644 --- a/Backend/app/spotify_electron/user/base_user_repository.py +++ b/Backend/app/spotify_electron/user/base_user_repository.py @@ -1,3 +1,8 @@ +""" +User repository for persisted data. +It uses the collection for the associated user type +""" + from pymongo.collection import Collection from app.logging.logging_constants import LOGGING_BASE_USERS_REPOSITORY diff --git a/Backend/app/spotify_electron/user/base_user_service.py b/Backend/app/spotify_electron/user/base_user_service.py index 16f02907..ec39bde3 100644 --- a/Backend/app/spotify_electron/user/base_user_service.py +++ b/Backend/app/spotify_electron/user/base_user_service.py @@ -1,3 +1,8 @@ +""" +Base User service for handling bussiness logic +Redirects to the specific user type service for non common logic +""" + import app.spotify_electron.playlist.playlist_service as playlist_service import app.spotify_electron.security.security_service as security_service import app.spotify_electron.user.artist.artist_service as artist_service diff --git a/Backend/app/spotify_electron/user/providers/user_collection_provider.py b/Backend/app/spotify_electron/user/providers/user_collection_provider.py index 1fb7a49f..e9ae970d 100644 --- a/Backend/app/spotify_electron/user/providers/user_collection_provider.py +++ b/Backend/app/spotify_electron/user/providers/user_collection_provider.py @@ -1,3 +1,7 @@ +""" +Provider class for supplying user collection connection with database depending on the architecture on the associated user type +""" + from pymongo.collection import Collection import app.spotify_electron.user.base_user_service as base_user_service diff --git a/Backend/app/spotify_electron/user/providers/user_service_provider.py b/Backend/app/spotify_electron/user/providers/user_service_provider.py index 9b10da9e..108eb8cc 100644 --- a/Backend/app/spotify_electron/user/providers/user_service_provider.py +++ b/Backend/app/spotify_electron/user/providers/user_service_provider.py @@ -1,3 +1,7 @@ +""" +Provider class for supplying service depending on associated user type +""" + from typing import Annotated, Any import app.spotify_electron.user.artist.artist_service as artist_service diff --git a/Backend/app/spotify_electron/user/user/user_repository.py b/Backend/app/spotify_electron/user/user/user_repository.py index 2cf0013a..b8fe55dc 100644 --- a/Backend/app/spotify_electron/user/user/user_repository.py +++ b/Backend/app/spotify_electron/user/user/user_repository.py @@ -1,3 +1,7 @@ +""" +User repository for managing persisted data +""" + import app.spotify_electron.user.providers.user_collection_provider as user_collection_provider from app.logging.logging_constants import LOGGING_USER_REPOSITORY from app.logging.logging_schema import SpotifyElectronLogger diff --git a/Backend/app/spotify_electron/user/user/user_schema.py b/Backend/app/spotify_electron/user/user/user_schema.py index 8217022e..cc4d7484 100644 --- a/Backend/app/spotify_electron/user/user/user_schema.py +++ b/Backend/app/spotify_electron/user/user/user_schema.py @@ -1,3 +1,7 @@ +""" +Song schema for User domain model +""" + from dataclasses import dataclass from enum import Enum diff --git a/Backend/app/spotify_electron/user/user/user_service.py b/Backend/app/spotify_electron/user/user/user_service.py index 4d77e05f..082786ab 100644 --- a/Backend/app/spotify_electron/user/user/user_service.py +++ b/Backend/app/spotify_electron/user/user/user_service.py @@ -1,3 +1,7 @@ +""" +User service for handling business logic +""" + import app.spotify_electron.security.security_service as security_service import app.spotify_electron.user.base_user_repository as base_user_repository import app.spotify_electron.user.base_user_service as base_user_service diff --git a/Backend/app/spotify_electron/user/user_controller.py b/Backend/app/spotify_electron/user/user_controller.py index f427fec1..91484a0c 100644 --- a/Backend/app/spotify_electron/user/user_controller.py +++ b/Backend/app/spotify_electron/user/user_controller.py @@ -1,3 +1,8 @@ +""" +User controller for handling incoming HTTP Requests +It uses the base_user_service for handling logic for different user types +""" + from typing import Annotated from fastapi import APIRouter, Header @@ -99,17 +104,6 @@ def get_user(name: str) -> Response: ) -@router.get("/{name}/playlists") -def get_playlists_by_user(name: str) -> Response: - # TODO get playlists by user - # TODO hacer test - - user = user_service.get_user(name) - user_json = json_converter_utils.get_json_from_model(user) - - return Response(user_json, media_type="application/json", status_code=200) - - @router.post("/") def create_user(name: str, photo: str, password: str) -> Response: """Create user diff --git a/Backend/app/spotify_electron/user/validations/base_users_repository_validations.py b/Backend/app/spotify_electron/user/validations/base_users_repository_validations.py index 437e7a5b..7a68ce3a 100644 --- a/Backend/app/spotify_electron/user/validations/base_users_repository_validations.py +++ b/Backend/app/spotify_electron/user/validations/base_users_repository_validations.py @@ -1,3 +1,7 @@ +""" +Validations for Common user repositories +""" + from pymongo.results import DeleteResult, InsertOneResult, UpdateResult from app.spotify_electron.user.user.user_schema import ( diff --git a/Backend/app/spotify_electron/user/validations/user_service_validations.py b/Backend/app/spotify_electron/user/validations/user_service_validations.py index 63d795ad..9b432bcb 100644 --- a/Backend/app/spotify_electron/user/validations/user_service_validations.py +++ b/Backend/app/spotify_electron/user/validations/user_service_validations.py @@ -1,3 +1,7 @@ +""" +Validations for Common user services +""" + from app.exceptions.base_exceptions_schema import BadParameterException from app.spotify_electron.user.user.user_schema import UserBadNameException from app.spotify_electron.utils.validations.validation_utils import validate_parameter diff --git a/Backend/app/spotify_electron/utils/audio_management/audio_management_utils.py b/Backend/app/spotify_electron/utils/audio_management/audio_management_utils.py index cb563dda..1f155548 100644 --- a/Backend/app/spotify_electron/utils/audio_management/audio_management_utils.py +++ b/Backend/app/spotify_electron/utils/audio_management/audio_management_utils.py @@ -1,3 +1,7 @@ +""" +Audio management utils +""" + import base64 import io diff --git a/Backend/app/spotify_electron/utils/date/date_utils.py b/Backend/app/spotify_electron/utils/date/date_utils.py index 8b3cb3e8..87e8fc24 100644 --- a/Backend/app/spotify_electron/utils/date/date_utils.py +++ b/Backend/app/spotify_electron/utils/date/date_utils.py @@ -1,7 +1,17 @@ +""" +Date utils +""" + from datetime import datetime -def get_current_iso8601_date(): +def get_current_iso8601_date() -> str: + """Get the current date in ISO8601 format + ISO8601 docs: https://www.iso.org/iso-8601-date-and-time-format.html + + Returns: + str: the ISO8601 current date + """ current_date = datetime.now() date_iso8601 = current_date.strftime("%Y-%m-%dT%H:%M:%S") return date_iso8601 diff --git a/Backend/app/spotify_electron/utils/json_converter/json_converter_utils.py b/Backend/app/spotify_electron/utils/json_converter/json_converter_utils.py index 056c2ad9..3ae6a848 100644 --- a/Backend/app/spotify_electron/utils/json_converter/json_converter_utils.py +++ b/Backend/app/spotify_electron/utils/json_converter/json_converter_utils.py @@ -1,3 +1,7 @@ +""" +Json converter utils for building HTTP Json responses from domain objects +""" + import json from typing import Any diff --git a/Backend/app/spotify_electron/utils/validations/validation_utils.py b/Backend/app/spotify_electron/utils/validations/validation_utils.py index 65e909d0..ded30715 100644 --- a/Backend/app/spotify_electron/utils/validations/validation_utils.py +++ b/Backend/app/spotify_electron/utils/validations/validation_utils.py @@ -1,3 +1,7 @@ +""" +Field common validations utils +""" + from typing import Any from app.exceptions.base_exceptions_schema import BadParameterException diff --git a/Backend/docker/build_and_up_dev.sh b/Backend/docker/build_and_up_dev.sh old mode 100644 new mode 100755 diff --git a/Backend/tests/test__properties_manager.py b/Backend/tests/test__properties_manager.py index f72ddd9e..542602f6 100644 --- a/Backend/tests/test__properties_manager.py +++ b/Backend/tests/test__properties_manager.py @@ -7,7 +7,6 @@ ARCHITECTURE_ENV_NAME, DEFAULT_ARCHITECTURE, DEV, - DISTRIBUTION_ID_ENV_NAME, ENV_VALUE_ENV_NAME, MONGO_URI_ENV_NAME, PROD, @@ -20,7 +19,6 @@ ARCHITECTURE_ENV_NAME: "ARCH", SECRET_KEY_SIGN_ENV_NAME: "SECRET_KEY_SIGN", MONGO_URI_ENV_NAME: "MONGO_URI", - DISTRIBUTION_ID_ENV_NAME: "DISTRIBUTION_ID", SERVERLESS_FUNCTION_URL_ENV_NAME: "SERVERLESS_FUNCTION_URL", ENV_VALUE_ENV_NAME: "ENV_VALUE", } From 0b319929805075eb48b542b5cda0d46319b77431 Mon Sep 17 00:00:00 2001 From: xiomara Date: Mon, 10 Jun 2024 13:09:00 -0400 Subject: [PATCH 4/4] Ignore D100 and D103 for files in the tests/ directory, enforce google pydoc --- Backend/ruff.toml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Backend/ruff.toml b/Backend/ruff.toml index ba84bd77..aab49209 100644 --- a/Backend/ruff.toml +++ b/Backend/ruff.toml @@ -24,6 +24,16 @@ extend-select = [ ignore = ["PLR0402","PLR0911"] +[lint.per-file-ignores] +"tests/**/*.py" = [ + "D100", # Ignore missing docstrings for public modules + "D103", # Ignore missing docstrings for public functions +] + +[lint.pydocstyle] +# Use Google-style docstrings +convention = "google" + [format] # Like Black, use double quotes for strings. quote-style = "double"