def test_foreign_account(self): parser = Parser() file_name = os.path.join(BASEPATH, "Coda_foreign_account.txt") statements = parser.parse_file(file_name) eq_(len(statements), 1) st = statements[0] eq_(st.acc_number, 'FR1234567890240924002304825') eq_(st.currency, 'EUR')
def test_parse_methods(self): parser = Parser() # test a invalid file name with assert_raises(ValueError): parser.parse_file('invalid_file_name') # test parsing from a path to a file parser = Parser() file_name = os.path.join(BASEPATH, "Coda_v2_3_single_statement.txt") statements = parser.parse_file(file_name) eq_(len(statements), 1) # test parsing from a file-like object parser = Parser() with open(os.path.join(file_name), 'rb'): statements = parser.parse_file(file_name) eq_(len(statements), 1) # test parsing an invalid content with assert_raises(ValueError) as cm: parser.parse(b'invalid_coda_content') ex = cm.exception eq_(str(ex), 'The given value is not a valid coda content')
def test_parse_methods(self): parser = Parser() # test a invalid file name with assert_raises(ValueError): parser.parse_file('invalid_file_name') # test parsing from a path to a file parser = Parser() file_name = os.path.join(BASEPATH, "Coda_v2_3_single_statement.txt") statements = parser.parse_file(file_name) eq_(len(statements), 1) # test parsing from a file-like object parser = Parser() with open(os.path.join(file_name)): statements = parser.parse_file(file_name) eq_(len(statements), 1) # test parsing an invalid content with assert_raises(ValueError) as cm: parser.parse('invalid_coda_content') ex = cm.exception eq_(ex.message, 'The given value is not a valid coda content')