from common import print_message
from src.interface.python_project import (
    PythonProjectInterface,
    get_aws_client,
    get_credentials,
    get_environment,
    sync_folder,
)

SQL_DATA_DIR = "sql_master_data"
WORK_BUCKET_NAME = "senior-datalake-artifacts"
ENVIRONMENT = get_environment()


class PythonAppDpsi(PythonProjectInterface):
    """
    Classe para gerenciar o projeto Python do DPSI (Data Platform Service Integration).
    """

    def __init__(self):
        super().__init__()
        self.work_bucket_name = (
            WORK_BUCKET_NAME
            if ENVIRONMENT == "prod"
            else f"{WORK_BUCKET_NAME}-{ENVIRONMENT}"
        )
        self.credentials = get_credentials(ENVIRONMENT)
        self.s3_client = get_aws_client("s3", self.credentials)

    def compile(self) -> None:
        print_message(
            "Projetos do tipo DPSI não possuem etapa de compile habilitada no CI, "
            "pois devem conter somente scripts SQL com as configurações dos Master Datas."
        )

    def package(self):
        """
        Sincroniza os arquivos SQL do diretório SQL_DATA_DIR para o bucket S3.
        """
        sync_folder(SQL_DATA_DIR, self.work_bucket_name, "", self.s3_client, ".sql")

    def unit_test(self) -> None:
        """
        Ignora testes unitários para o projeto DPSI.
        """
        print_message(
            "Projetos do tipo DPSI não possuem Unit Tests habilitados no CI, "
            "pois devem conter somente scripts SQL com as configurações dos Master Datas."
        )
