Skip to content

Commit

Permalink
test: Add test for schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
scjorge committed Jul 30, 2024
1 parent 83ec4b1 commit f37d926
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions tests/test_base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from pydantic import BaseModel
import pytest

from pydantic_br import (
CPF,
CNH,
CPFMask,
CPFDigits,
CNPJ,
CNPJDigits,
CNPJMask,
TE,
PIS,
PISMask,
PISDigits,
Certidao,
CertidaoMask,
CertidaoDigits,
)

from pydantic_br.get_versions import get_pydantic_version, PydanticVersion


@pytest.fixture(scope="session")
def model():
class GeneralModel(BaseModel):
cpf: CPF = "661.554.170-08"
cpf_mask: CPFMask = "661.554.170-08"
cpf_digits: CPFDigits = "66155417008"
cnh: CNH = "49761142867"
cnpj: CNPJ = "80.680.038/0001-91"
cnpj_digits: CNPJDigits = "80680038000191"
cnpj_mask: CNPJMask = "80.680.038/0001-91"
te: TE = "526340880167"
pis: PIS = "977.75868.13-5"
pis_mask: PISMask = "977.75868.13-5"
pis_digits: PISDigits = "97775868135"
certidao: Certidao = "13324601552017174927061644649830"
certidao_mask: CertidaoMask = "133246.01.55.2017.1.74927.061.6446498.30"
certidao_digits: CertidaoDigits = "13324601552017174927061644649830"

general_model = GeneralModel()
return general_model


def test_model_schemas(model: BaseModel):
if get_pydantic_version() == PydanticVersion.v2:
model.model_dump()
model.model_dump_json()
model.model_json_schema()
if get_pydantic_version() == PydanticVersion.v1:
model.dict()
model.schema()

0 comments on commit f37d926

Please sign in to comment.