You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
2.4 KiB
78 lines
2.4 KiB
from pandas import DataFrame, merge, to_datetime, NaT, concat, read_excel
|
|
from pathlib import Path
|
|
from re import Pattern
|
|
import pytest as pt
|
|
|
|
from src.config import ReportConfig, ReportSource
|
|
from src.reports import GreatPlainsReport, OnBaseReport, ReconciledReports
|
|
from src.hold_reconciler import pull_report_sheet
|
|
|
|
class TestReport:
|
|
|
|
@pt.fixture(autouse=True)
|
|
def setup(self):
|
|
self.report_config = ReportConfig.from_file(
|
|
Path(r"./tests/test_inputs/TEST_reports_config.toml")
|
|
)
|
|
|
|
|
|
def test_full(self):
|
|
"""
|
|
Full process test.
|
|
|
|
This tests inputs will need to be adjust anytime a change is made to the
|
|
input/output report layouts, filtering, trimming, normalization.
|
|
|
|
Basically, this is just to make sure everything still works after making
|
|
TINY changes, that are not meant to effect the structure/logic of the program
|
|
"""
|
|
|
|
ob_df = pull_report_sheet(
|
|
Path(r"./tests/test_inputs\Static\April 2023 OB.xlsx"),
|
|
ReportSource.OB,
|
|
self.report_config
|
|
)
|
|
gp_df = pull_report_sheet(
|
|
Path(r"./tests/test_inputs\Static\April GP.xlsx"),
|
|
ReportSource.GP,
|
|
self.report_config
|
|
)
|
|
|
|
assert not ob_df.empty, "OB Data empty!"
|
|
assert not gp_df.empty, "GP Data empty!"
|
|
|
|
obr: OnBaseReport = OnBaseReport(ob_df, self.report_config)
|
|
gpr: GreatPlainsReport = GreatPlainsReport(gp_df, self.report_config)
|
|
|
|
rec_output: ReconciledReports = obr.reconcile(gpr)
|
|
|
|
output_path: Path = Path(
|
|
self.report_config.paths.output_directory,
|
|
"TEST_REPORT.xlsx"
|
|
)
|
|
rec_output.save_reports(output_path)
|
|
|
|
SHEET_NAMES = [
|
|
"No Match",
|
|
"Amount Mismatch",
|
|
"Overdue",
|
|
"Previously Reconciled",
|
|
"Filtered from GP",
|
|
]
|
|
|
|
CONTROL: dict[str:DataFrame] = read_excel(
|
|
Path(r"./tests/test_inputs/Static/Reconciled Holds [TEST_FIN].xlsx"),
|
|
sheet_name=SHEET_NAMES
|
|
)
|
|
|
|
new: dict[str:DataFrame] = read_excel(
|
|
output_path,
|
|
sheet_name=SHEET_NAMES
|
|
)
|
|
|
|
for sheet in SHEET_NAMES:
|
|
print(sheet)
|
|
print(new[sheet])
|
|
print("Control: ")
|
|
print(CONTROL[sheet])
|
|
assert new[sheet].equals(CONTROL[sheet])
|
|
|