1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
import pytest
from inline_snapshot import snapshot
from odmantic import Model
def test_config_enforced_pydantic_option():
with pytest.raises(ValueError) as exc_info:
class M(Model):
a: int
model_config = {"validate_assignment": True}
assert str(exc_info.value) == snapshot(
"'M': configuration attribute 'validate_assignment' is enforced to True by ODMantic and cannot be changed" # noqa: E501
)
def test_config_unsupported_pydantic_option():
with pytest.raises(ValueError) as exc_info:
class M(Model):
a: int
model_config = {"frozen": True}
assert str(exc_info.value) == snapshot(
"'M': configuration attribute 'frozen' from Pydantic is not supported"
)
def test_config_unknown_option():
with pytest.raises(ValueError) as exc_info:
class M(Model):
a: int
model_config = {"this_config_doesnt_exist": True}
assert str(exc_info.value) == snapshot(
"'M': unknown configuration attribute 'this_config_doesnt_exist'"
)
|