b4w export: some more tests
This commit is contained in:
+9
-1
@@ -46,7 +46,15 @@ class B4wExport(BaseModel):
|
||||
reference: str = Field(alias="RmtInf")
|
||||
other_name: str = Field(alias="RmtdNm")
|
||||
other_iban: str = Field(alias="RmtdAcctIBAN")
|
||||
category: Category | None = Field(alias="Category")
|
||||
category: Category | None = Field(
|
||||
alias="Category",
|
||||
examples=[
|
||||
"Freizeit",
|
||||
"Beruf:Gehalt:super Firma",
|
||||
"Lebenshaltung:Lebensmitteleinkäuft",
|
||||
"",
|
||||
],
|
||||
)
|
||||
notes: str = Field(alias="Notes")
|
||||
|
||||
@property
|
||||
|
||||
+2
-1
@@ -5,4 +5,5 @@ from src.models import B4wExport
|
||||
DEFAULT_CATEGORY = "root_category:parent_category:leaf_category"
|
||||
|
||||
|
||||
class B4wExportFactory(ModelFactory[B4wExport]): ...
|
||||
class B4wExportFactory(ModelFactory[B4wExport]):
|
||||
__use_examples__ = True
|
||||
|
||||
@@ -1,13 +1,31 @@
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from src.models import B4wExport, Category
|
||||
from tests.factories import B4wExportFactory
|
||||
|
||||
|
||||
def test_b4wexport_simple():
|
||||
def test_b4w_export_simple():
|
||||
data = B4wExportFactory.build()
|
||||
assert isinstance(data, B4wExport)
|
||||
|
||||
|
||||
def test_b4export_category():
|
||||
def test_b4w_export_category():
|
||||
data = B4wExportFactory.build(Category="fun:stuff")
|
||||
assert isinstance(data.category, Category)
|
||||
assert data.category.to_str() == "fun:stuff"
|
||||
|
||||
|
||||
def test_b4w_export_account_iban_invalid():
|
||||
with pytest.raises(ValidationError):
|
||||
_ = B4wExportFactory.build(OwnrAcctIBAN="not an IBAN")
|
||||
|
||||
|
||||
def test_b4w_export_account_iban_to_long():
|
||||
with pytest.raises(ValidationError):
|
||||
_ = B4wExportFactory.build(OwnrAcctIBAN="DE990123456789012345678901234567890")
|
||||
|
||||
|
||||
def test_b4w_export_account_iban_to_short():
|
||||
with pytest.raises(ValidationError):
|
||||
_ = B4wExportFactory.build(OwnrAcctIBAN="DE123")
|
||||
|
||||
Reference in New Issue
Block a user