mypy black ruff
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"""Tests for src.models.__init__.py lazy loading and __dir__."""
|
||||
|
||||
import pytest
|
||||
|
||||
from src import models
|
||||
|
||||
|
||||
@@ -10,50 +11,58 @@ class TestLazyLoading:
|
||||
def test_load_b4wexport(self):
|
||||
"""Test loading B4wExport model."""
|
||||
from src.models.b4w import B4wExport as DirectB4wExport
|
||||
|
||||
b4w = models.B4wExport
|
||||
assert b4w is DirectB4wExport
|
||||
|
||||
def test_load_category(self):
|
||||
"""Test loading Category model."""
|
||||
from src.models.category import Category as DirectCategory
|
||||
|
||||
cat = models.Category
|
||||
assert cat is DirectCategory
|
||||
|
||||
def test_load_categorybudgetdb(self):
|
||||
"""Test loading CategoryBudgetDb model."""
|
||||
from src.models.category import CategoryBudgetDb as DirectCategoryBudgetDb
|
||||
|
||||
cbdb = models.CategoryBudgetDb
|
||||
assert cbdb is DirectCategoryBudgetDb
|
||||
|
||||
def test_load_comdirectgiro(self):
|
||||
"""Test loading ComdirectGiro model."""
|
||||
from src.models.comdirect import ComdirectGiro as DirectComdirectGiro
|
||||
|
||||
giro = models.ComdirectGiro
|
||||
assert giro is DirectComdirectGiro
|
||||
|
||||
def test_load_transaction(self):
|
||||
"""Test loading Transaction model."""
|
||||
from src.models.transactions import Transaction as DirectTransaction
|
||||
|
||||
tx = models.Transaction
|
||||
assert tx is DirectTransaction
|
||||
|
||||
def test_load_account(self):
|
||||
"""Test loading Account model."""
|
||||
from src.models.settings import Account as DirectAccount
|
||||
|
||||
acc = models.Account
|
||||
assert acc is DirectAccount
|
||||
|
||||
def test_load_source(self):
|
||||
"""Test loading Source model."""
|
||||
from src.models.settings import Source as DirectSource
|
||||
|
||||
src = models.Source
|
||||
assert src is DirectSource
|
||||
|
||||
def test_nonexistent_attribute_raises(self):
|
||||
"""Test that non-existent attributes raise AttributeError."""
|
||||
with pytest.raises(AttributeError) as exc_info:
|
||||
models.NonExistentModel
|
||||
|
||||
# This is intentional: testing that accessing a non-existent attribute raises
|
||||
_ = models.NonExistentModel # type: ignore[name-defined]
|
||||
|
||||
expected_msg = "module 'src.models' has no attribute 'NonExistentModel'"
|
||||
assert expected_msg in str(exc_info.value)
|
||||
|
||||
@@ -71,7 +80,7 @@ class TestDirMethod:
|
||||
def test_dir_includes_all_exports(self):
|
||||
"""Test that __dir__() includes all exported models."""
|
||||
result = models.__dir__()
|
||||
|
||||
|
||||
expected_exports = {
|
||||
"B4wExport",
|
||||
"Category",
|
||||
@@ -84,7 +93,7 @@ class TestDirMethod:
|
||||
"Transaction",
|
||||
"TransactionDb",
|
||||
}
|
||||
|
||||
|
||||
# All exports should be in dir()
|
||||
for export_name in expected_exports:
|
||||
assert export_name in result
|
||||
|
||||
Reference in New Issue
Block a user