personal-finance-database/tests/test_pdf_parser.py

29 lines
752 B
Python

import pandas as pd
import pytest
from pdf_parser import DBSCreditCardStatementParser
def test_dbs_credit_card_statement_parser():
# The path to a sample PDF file to use for testing
sample_pdf_path = "tests/sample_dbs_statement.pdf"
# Initialize the parser
parser = DBSCreditCardStatementParser(sample_pdf_path)
# Parse the PDF file
df = parser.parse()
# Check the DataFrame's columns
assert list(df.columns) == [
"Card Last 4 Digits",
"TRANS DATE",
"POST DATE",
"DESCRIPTION",
"AMOUNT HKD",
"RUNNING BALANCE",
]
# Check the DataFrame's number of rows
# (Replace 21 with the actual number of transactions in the sample PDF file)
assert len(df) == 21