diff --git a/conservancy_beancount/reports/accrual.py b/conservancy_beancount/reports/accrual.py index b00ee283c45e6ea6c1fdf6d10511ceba125b1342..30e0fb58cfbf4c791ae5f3f8bab7d346abedad46 100644 --- a/conservancy_beancount/reports/accrual.py +++ b/conservancy_beancount/reports/accrual.py @@ -293,13 +293,12 @@ class AgingODS(core.BaseODS[AccrualPostings, Optional[data.Account]]): COL_COUNT = len(COLUMNS) def __init__(self, - rt_client: rt.Rt, + rt_wrapper: rtutil.RT, date: datetime.date, logger: logging.Logger, ) -> None: super().__init__() - self.rt_client = rt_client - self.rt_wrapper = rtutil.RT(self.rt_client) + self.rt_wrapper = rt_wrapper self.date = date self.logger = logger @@ -445,7 +444,7 @@ class AgingODS(core.BaseODS[AccrualPostings, Optional[data.Account]]): class AgingReport(BaseReport): def __init__(self, - rt_client: rt.Rt, + rt_wrapper: rtutil.RT, out_file: BinaryIO, date: Optional[datetime.date]=None, ) -> None: @@ -453,7 +452,7 @@ class AgingReport(BaseReport): date = datetime.date.today() self.out_bin = out_file self.logger = logger.getChild(type(self).__name__) - self.ods = AgingODS(rt_client, date, self.logger) + self.ods = AgingODS(rt_wrapper, date, self.logger) def run(self, groups: PostGroups) -> None: rows: List[AccrualPostings] = [] @@ -501,10 +500,10 @@ class BalanceReport(BaseReport): class OutgoingReport(BaseReport): - def __init__(self, rt_client: rt.Rt, out_file: TextIO) -> None: + def __init__(self, rt_wrapper: rtutil.RT, out_file: TextIO) -> None: super().__init__(out_file) - self.rt_client = rt_client - self.rt_wrapper = rtutil.RT(rt_client) + self.rt_wrapper = rt_wrapper + self.rt_client = rt_wrapper.rt def _primary_rt_id(self, posts: AccrualPostings) -> rtutil.TicketAttachmentIds: rt_id = posts.rt_id @@ -721,8 +720,8 @@ def main(arglist: Optional[Sequence[str]]=None, report: Optional[BaseReport] = None output_path: Optional[Path] = None if args.report_type is ReportType.AGING: - rt_client = config.rt_client() - if rt_client is None: + rt_wrapper = config.rt_wrapper() + if rt_wrapper is None: logger.error("unable to generate aging report: RT client is required") else: now = datetime.datetime.now() @@ -730,14 +729,14 @@ def main(arglist: Optional[Sequence[str]]=None, args.output_file = Path(now.strftime('AgingReport_%Y-%m-%d_%H:%M.ods')) logger.info("Writing report to %s", args.output_file) out_bin = cliutil.bytes_output(args.output_file, stdout) - report = AgingReport(rt_client, out_bin) + report = AgingReport(rt_wrapper, out_bin) elif args.report_type is ReportType.OUTGOING: - rt_client = config.rt_client() - if rt_client is None: + rt_wrapper = config.rt_wrapper() + if rt_wrapper is None: logger.error("unable to generate outgoing report: RT client is required") else: out_file = cliutil.text_output(args.output_file, stdout) - report = OutgoingReport(rt_client, out_file) + report = OutgoingReport(rt_wrapper, out_file) else: out_file = cliutil.text_output(args.output_file, stdout) report = BalanceReport(out_file) diff --git a/setup.py b/setup.py index a7c1cf5167114091b019291725916695c95d15a7..7b0f64268c502658541863173f1ec34119a9b2a2 100755 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ from setuptools import setup setup( name='conservancy_beancount', description="Plugin, library, and reports for reading Conservancy's books", - version='1.1.9', + version='1.1.10', author='Software Freedom Conservancy', author_email='info@sfconservancy.org', license='GNU AGPLv3+', diff --git a/tests/test_reports_accrual.py b/tests/test_reports_accrual.py index 6b7ab910cc2f1bffd3c2f9773fc096210b52f034..676d2ae4986627bb49f0ee4f0ccfa862707e0ca6 100644 --- a/tests/test_reports_accrual.py +++ b/tests/test_reports_accrual.py @@ -425,10 +425,11 @@ def check_output(output, expect_patterns): def run_outgoing(rt_id, postings, rt_client=None): if rt_client is None: rt_client = RTClient() + rt_wrapper = rtutil.RT(rt_client) if not isinstance(postings, core.RelatedPostings): postings = accruals_by_meta(postings, rt_id, 'rt-id', wrap_type=accrual.AccrualPostings) output = io.StringIO() - report = accrual.OutgoingReport(rt_client, output) + report = accrual.OutgoingReport(rt_wrapper, output) report.run({rt_id: postings}) return output @@ -525,8 +526,8 @@ def run_aging_report(postings, today=None): for key, group in related.make_consistent() } output = io.BytesIO() - rt_client = RTClient() - report = accrual.AgingReport(rt_client, output, today) + rt_wrapper = rtutil.RT(RTClient()) + report = accrual.AgingReport(rt_wrapper, output, today) report.run(groups) return output