def test_transaction_fields(): """Does the mapping have feasible entries?""" our_names = [c.name for c in TransactionColumns] for bbt, ours in Bbt.field_2_transaction().items(): assert bbt in Bbt.field_names() assert ours in our_names
def test_parse(bbt_file_fixture): """Does a normal file get parsed?""" assert Bbt.is_file_parsable(bbt_file_fixture) frame = Bbt(bbt_file_fixture).parse().frame rows, cols = frame.shape # MAGIC minus 1 for the header assert rows == FAKE_BBT_TRANSACTIONS.count('\n') - 1
def bbt_instance(bbt_file_fixture): bbt = Bbt(bbt_file_fixture) print(bbt.account) yield bbt
def test_scrape_account_no_match(): """Does the account number get extracted for a bad filename?""" path = os.path.join("/", "arbitrary", "dir", Bbt.FILE_PREFIX + "not 4 digits") assert Bbt.parse_account_number(path) is None
def test_scrape_account(): """Does the account number get extracted from the filename?""" path = os.path.join("/", "arbitrary", "dir", expected_filename()) account = Bbt.parse_account_number(path) assert FAKE_BBT_ACCOUNT == int(account)
def test_check_filename_reject(): """Does an invalid filename get rejected?""" bad_filename = rand_string(4) + expected_filename() assert not Bbt._check_filename(bad_filename)
def test_check_filename_path(): """Does a valid file path pass?""" path = os.path.join("/", "arbitrary", "dir", expected_filename()) assert Bbt._check_filename(path)
def test_reject_filename(): """Does an invalid filename get rejected?""" # MAGIC offset account no. filename = str(12345) + expected_filename() assert not Bbt._check_filename(filename)
def test_check_filename(): """Does a valid filename pass?""" assert Bbt._check_filename(expected_filename())