Initial release: async repository layer over SQLModel

This commit is contained in:
2026-08-13 22:25:59 +03:00
commit 3d85c2b5dd
26 changed files with 2252 additions and 0 deletions

40
tests/test_tables.py Normal file
View File

@@ -0,0 +1,40 @@
import pytest
from sqlmodel import Field
from metaorm import BaseTable
from tests.models import User
class TestBaseTable:
def test_to_values_returns_column_data(self) -> None:
from tests.models import UserTable
user_table = UserTable(id=1, name="Alice", email="alice@example.com")
values = user_table.to_values()
assert values == {
"id": 1,
"name": "Alice",
"email": "alice@example.com",
}
def test_from_item_not_implemented_in_base_class(self) -> None:
class DummyFromItemTable(BaseTable[User], table=True):
__tablename__ = "dummy_from_item"
id: int | None = Field(default=None, primary_key=True)
with pytest.raises(NotImplementedError):
DummyFromItemTable.from_item(
User(name="Alice", email="alice@example.com"),
)
def test_to_item_not_implemented_in_base_class(self) -> None:
class DummyToItemTable(BaseTable[User], table=True):
__tablename__ = "dummy_to_item"
id: int | None = Field(default=None, primary_key=True)
dummy = DummyToItemTable(id=1, name="Alice", email="alice@example.com")
with pytest.raises(NotImplementedError):
dummy.to_item()