refactor: migrate to keyword-based repository config, add nested transactions and tests
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from metaorm import DatabaseSettings
|
||||
from metaorm import RepositorySettings
|
||||
|
||||
|
||||
class TestDatabaseSettings:
|
||||
class TestRepositorySettings:
|
||||
def test_default_values(self) -> None:
|
||||
settings = DatabaseSettings()
|
||||
settings = RepositorySettings()
|
||||
|
||||
assert settings.dsn == "sqlite+aiosqlite:///db.sqlite3"
|
||||
assert settings.pool_size == 5
|
||||
@@ -14,7 +14,7 @@ class TestDatabaseSettings:
|
||||
assert settings.pool_timeout == 60
|
||||
|
||||
def test_custom_values(self) -> None:
|
||||
settings = DatabaseSettings(
|
||||
settings = RepositorySettings(
|
||||
dsn="postgresql+asyncpg://user:pass@localhost/db",
|
||||
pool_size=10,
|
||||
pool_recycle=120,
|
||||
@@ -28,7 +28,7 @@ class TestDatabaseSettings:
|
||||
|
||||
def test_dsn_must_match_pattern(self) -> None:
|
||||
with pytest.raises(ValidationError):
|
||||
DatabaseSettings(dsn="invalid_dsn")
|
||||
RepositorySettings(dsn="invalid_dsn")
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"field_name,invalid_value",
|
||||
@@ -44,4 +44,4 @@ class TestDatabaseSettings:
|
||||
invalid_value: int,
|
||||
) -> None:
|
||||
with pytest.raises(ValidationError):
|
||||
DatabaseSettings(**{field_name: invalid_value})
|
||||
RepositorySettings(**{field_name: invalid_value})
|
||||
|
||||
Reference in New Issue
Block a user