from pydantic import BaseModel

from keble_helpers.typings import PydanticModelConfig


def test_pydantic_model_config_default_dict():
    config = PydanticModelConfig.default_dict(validate_assignment=True)
    assert config["populate_by_name"] is True
    assert callable(config["alias_generator"])
    assert config["validate_assignment"] is True


def test_pydantic_model_config_default_allows_alias_and_field_name():
    class Example(BaseModel):
        model_config = PydanticModelConfig.default()

        some_field: int

    assert Example(some_field=1).some_field == 1
    assert Example(someField=2).some_field == 2
    assert Example(someField=3).model_dump(by_alias=True)["someField"] == 3
