def test_identify_with_formatted_iban(self): importer = ECImporter(self.formatted_iban, 'Assets:DKB:EC') with open(self.filename, 'wb') as fd: fd.write(_format(''' "Kontonummer:";"{iban} / Girokonto"; "Von:";"01.01.2018"; "Bis:";"31.01.2018"; "Kontostand vom 31.01.2018:";"5.000,01 EUR"; {header}; ''', dict(iban=self.iban, header=HEADER))) with open(self.filename) as fd: self.assertTrue(importer.identify(fd))
def test_identify_with_exotic_account_name(self): importer = ECImporter(self.iban, 'Assets:DKB:EC') with open(self.filename, 'wb') as fd: fd.write(_format(''' "Kontonummer:";"{iban} / Girökóntô, Γιροκοντώ, 預金, حساب البنك"; "Von:";"01.01.2018"; "Bis:";"31.01.2018"; "Kontostand vom 31.01.2018:";"5.000,01 EUR"; {header}; ''', dict(iban=self.iban, header=HEADER))) with open(self.filename) as fd: self.assertTrue(importer.identify(fd))
def test_identify_with_formatted_iban(tmp_file): importer = ECImporter(Constants.formatted_iban.value, 'Assets:DKB:EC') tmp_file.write( _format( ''' "Kontonummer:";"{iban} / Girokonto"; "Von:";"01.01.2018"; "Bis:";"31.01.2018"; "Kontostand vom 31.01.2018:";"5.000,01 EUR"; {header}; ''', dict(iban=Constants.iban.value, header=Constants.header.value), )) with open(str(tmp_file.realpath())) as fd: assert importer.identify(fd)
def test_identify_with_exotic_account_name(tmp_file): importer = ECImporter(Constants.iban.value, 'Assets:DKB:EC') tmp_file.write( _format( ''' "Kontonummer:";"{iban} / Girökóntô, Γιροκοντώ, 預金, حساب البنك"; "Von:";"01.01.2018"; "Bis:";"31.01.2018"; "Kontostand vom 31.01.2018:";"5.000,01 EUR"; {header}; ''', # NOQA dict(iban=Constants.iban.value, header=Constants.header.value), )) with open(str(tmp_file.realpath())) as fd: assert importer.identify(fd)
def test_identify_with_formatted_iban(tmp_file): importer = ECImporter(FORMATTED_IBAN, 'Assets:DKB:EC') tmp_file.write_text( _format( ''' "Kontonummer:";"{iban} / Girokonto"; "Von:";"01.01.2018"; "Bis:";"31.01.2018"; "Kontostand vom 31.01.2018:";"5.000,01 EUR"; {header}; ''', dict(iban=IBAN, header=HEADER), ) ) with tmp_file.open() as fd: assert importer.identify(fd)
def test_identify_with_exotic_account_name(tmp_file): importer = ECImporter(IBAN, 'Assets:DKB:EC') tmp_file.write_text( _format( ''' "Kontonummer:";"{iban} / Girökóntô, Γιροκοντώ, 預金, حساب البنك"; "Von:";"01.01.2018"; "Bis:";"31.01.2018"; "Kontostand vom 31.01.2018:";"5.000,01 EUR"; {header}; ''', # NOQA dict(iban=IBAN, header=HEADER), ) ) with tmp_file.open() as fd: assert importer.identify(fd)
def test_identify_with_nonstandard_account_name(tmp_file): importer = ECImporter(IBAN, 'Assets:DKB:EC') tmp_file.write_text( _format( ''' "Kontonummer:";"{iban} / My Custom Named Account"; "Von:";"01.01.2018"; "Bis:";"31.01.2018"; "Kontostand vom 31.01.2018:";"5.000,01 EUR"; {header}; ''', dict(iban=IBAN, header=HEADER), ) ) with tmp_file.open() as fd: assert importer.identify(fd)
def test_identify_invalid_iban(tmp_file): other_iban = 'DE00000000000000000000' tmp_file.write_text( _format( ''' "Kontonummer:";"{iban} / Girokonto"; "Von:";"01.01.2018"; "Bis:";"31.01.2018"; "Kontostand vom 31.01.2018:";"5.000,01 EUR"; {header}; ''', dict(iban=IBAN, header=HEADER), ) ) importer = ECImporter(other_iban, 'Assets:DKB:EC') with tmp_file.open() as fd: assert not importer.identify(fd)