From 26c2a3a7ecebaf7b5b837832cfa3c86e5c718159 Mon Sep 17 00:00:00 2001 From: Augusto Herrmann Date: Thu, 22 Aug 2024 16:41:21 -0300 Subject: [PATCH] Rename Pydantic models to disambiguate --- src/schemas.py | 14 +++++++------- tests/test_validate_yaml_schemas.py | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/schemas.py b/src/schemas.py index 6a88809..faadafd 100644 --- a/src/schemas.py +++ b/src/schemas.py @@ -46,7 +46,7 @@ class SearchField(BaseModel): value: str -class Search(BaseModel): +class SearchConfig(BaseModel): """Represents the search configuration in the YAML file.""" header: Optional[str] = Field( @@ -70,7 +70,7 @@ class Search(BaseModel): ) -class Report(BaseModel): +class ReportConfig(BaseModel): """Represents the report configuration in the YAML file.""" slack: Optional[dict] = Field( @@ -107,7 +107,7 @@ class Report(BaseModel): ) -class DAG(BaseModel): +class DAGConfig(BaseModel): """Represents the DAG configuration in the YAML file.""" id: str = Field(description="Nome único da DAG") @@ -120,17 +120,17 @@ class DAG(BaseModel): ) schedule: Optional[str] = Field(default=None, description="Expressão cron") dataset: Optional[str] = Field(default=None, description="Nome do Dataset") - search: Union[List[Search], Search] = Field( + search: Union[List[SearchConfig], SearchConfig] = Field( description="Seção para definição da busca no Diário" ) doc_md: Optional[str] = Field(default="", description="description") - report: Report = Field( + report: ReportConfig = Field( description="Aceita: `slack`, `discord`, `emails`, `attach_csv`, " "`subject`, `skip_null`" ) -class Config(BaseModel): +class RoDouConfig(BaseModel): """Represents the overall configuration in the YAML file.""" - dag: DAG = Field(description="Instanciação da DAG") + dag: DAGConfig = Field(description="Instanciação da DAG") diff --git a/tests/test_validate_yaml_schemas.py b/tests/test_validate_yaml_schemas.py index 0c0d335..fedfadd 100644 --- a/tests/test_validate_yaml_schemas.py +++ b/tests/test_validate_yaml_schemas.py @@ -11,7 +11,7 @@ # add module path so we can import from other modules sys.path.insert(0, os.path.abspath(os.path.dirname(__file__))) -from schemas import Config +from schemas import RoDouConfig YAMLS_DIR = "../dags/ro_dou/dag_confs" @@ -29,6 +29,6 @@ def test_pydantic_validation(data_file): data = yaml.safe_load(data_fp) try: - Config(**data) + RoDouConfig(**data) except ValidationError as e: pytest.fail(f"YAML file {data_file} is not valid:\n{e}")