fix b4w real-world import
This commit is contained in:
+8
-2
@@ -34,6 +34,13 @@ def _iban() -> str:
|
||||
return B4wExportFactory.__faker__.iban()
|
||||
|
||||
|
||||
def _other_iban() -> str:
|
||||
faker = B4wExportFactory.__faker__
|
||||
if faker.pyint(min_value=0, max_value=100) < 50:
|
||||
return ""
|
||||
return faker.iban()
|
||||
|
||||
|
||||
class B4wExportFactory(ModelFactory[B4wExport]):
|
||||
__faker__ = Faker("de_DE")
|
||||
__use_examples__ = True
|
||||
@@ -43,7 +50,7 @@ class B4wExportFactory(ModelFactory[B4wExport]):
|
||||
Notes = Use(_sentence)
|
||||
RmtdNm = Use(_names)
|
||||
OwnrAcctIBAN = Use(_iban)
|
||||
RmtdAcctIBAN = Use(_iban)
|
||||
RmtdAcctIBAN = Use(_other_iban)
|
||||
|
||||
|
||||
class ComdirectGiroFactory(ModelFactory[ComdirectGiro]):
|
||||
@@ -61,4 +68,3 @@ class ComdirectCreditCardFactory(ModelFactory[ComdirectCreditCard]):
|
||||
class ComdirectDepotFactory(ModelFactory[ComdirectDepot]):
|
||||
__faker__ = Faker("de_DE")
|
||||
__use_example__ = True
|
||||
|
||||
|
||||
@@ -33,6 +33,27 @@ def test_b4w_export_account_iban_to_short():
|
||||
_ = B4wExportFactory.build(OwnrAcctIBAN="DE123")
|
||||
|
||||
|
||||
def test_b4w_export_other_iban_empty_is_none():
|
||||
data = B4wExportFactory.build(RmtdAcctIBAN="")
|
||||
assert data.other_iban is None
|
||||
|
||||
|
||||
def test_b4w_export_other_iban_blank_is_none():
|
||||
data = B4wExportFactory.build(RmtdAcctIBAN=" ")
|
||||
assert data.other_iban is None
|
||||
|
||||
|
||||
def test_b4w_export_other_iban_invalid():
|
||||
with pytest.raises(ValidationError):
|
||||
_ = B4wExportFactory.build(RmtdAcctIBAN="not an IBAN")
|
||||
|
||||
|
||||
def test_b4w_export_other_iban_repr_round_trip_empty():
|
||||
data = B4wExportFactory.build(RmtdAcctIBAN="")
|
||||
data2 = eval(str(data))
|
||||
assert data == data2
|
||||
|
||||
|
||||
def test_b4w_export_parameters_to_dict():
|
||||
data = B4wExportFactory.build()
|
||||
params = data.parameters_to_dict()
|
||||
|
||||
Reference in New Issue
Block a user