Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_bic():
bic = BIC("GENODEM1GLS")
assert bic.formatted == "GENO DE M1 GLS"
assert bic.validate()
def test_bic_allow_invalid():
bic = BIC("GENODXM1GLS", allow_invalid=True)
assert bic
assert bic.country_code == "DX"
with pytest.raises(ValueError):
bic.validate()
def test_bic_properties():
bic = BIC("GENODEM1GLS")
assert bic.length == 11
assert bic.bank_code == "GENO"
assert bic.country_code == "DE"
assert bic.location_code == "M1"
assert bic.branch_code == "GLS"
assert bic.domestic_bank_codes == ["43060967", "43060988"]
assert bic.bank_names == [
"GLS Gemeinschaftsbank",
"GLS Gemeinschaftsbank (GAA)",
]
assert bic.bank_short_names == [
"GLS Bank in Bochum (GAA)",
"GLS Gemeinschaftsbk Bochum",
]
assert bic.country == countries.get(alpha_2="DE")
with pytest.warns(DeprecationWarning):
def test_magic_methods():
bic = BIC("GENODEM1GLS")
assert bic == "GENODEM1GLS"
assert bic == BIC("GENODEM1GLS")
assert bic != BIC("GENODEMMXXX")
assert bic != 12345
assert bic < "GENODEM1GLT"
assert str(bic) == "GENODEM1GLS"
assert hash(bic) == hash("GENODEM1GLS")
assert repr(bic) == ""
def test_bic_no_branch_code():
bic = BIC("GENODEM1")
assert bic.branch_code is None
assert bic.formatted == "GENO DE M1"
def test_invalid_bic(code):
with pytest.raises(ValueError):
BIC(code)
def test_unknown_bic_properties():
bic = BIC("ABNAJPJTXXX")
assert bic.length == 11
assert bic.bank_code == "ABNA"
assert bic.country_code == "JP"
assert bic.location_code == "JT"
assert bic.branch_code == "XXX"
assert bic.country_bank_code is None
assert bic.domestic_bank_codes == []
assert bic.bank_name is None
assert bic.bank_names == []
assert bic.bank_short_name is None
assert bic.bank_short_names == []
assert not bic.exists
assert bic.type == "default"
def test_magic_methods():
bic = BIC("GENODEM1GLS")
assert bic == "GENODEM1GLS"
assert bic == BIC("GENODEM1GLS")
assert bic != BIC("GENODEMMXXX")
assert bic != 12345
assert bic < "GENODEM1GLT"
assert str(bic) == "GENODEM1GLS"
assert hash(bic) == hash("GENODEM1GLS")
assert repr(bic) == ""
def test_magic_methods():
bic = BIC("GENODEM1GLS")
assert bic == "GENODEM1GLS"
assert bic == BIC("GENODEM1GLS")
assert bic != BIC("GENODEMMXXX")
assert bic != 12345
assert bic < "GENODEM1GLT"
assert str(bic) == "GENODEM1GLS"
assert hash(bic) == hash("GENODEM1GLS")
assert repr(bic) == ""
if self.mandate_state == "bounced":
return SepaDirectDebitState.BOUNCED
if self.mandate_state == "inactive":
return SepaDirectDebitState.INACTIVE
if not self.bic_autocomplete:
return SepaDirectDebitState.NO_BIC
bic = self.bic_parsed
if not bic:
return SepaDirectDebitState.INVALID_BIC
if bic.country_code == "DE" and not bic.exists:
# PBNKDEFF and PBNKDEFFXXX should be the same
b_ = BIC(str(bic) + "XXX")
if not b_.exists:
return SepaDirectDebitState.INVALID_BIC
if not self.mandate_reference:
return SepaDirectDebitState.NO_MANDATE_REFERENCE
return SepaDirectDebitState.OK