def call_divcal(self, other_args: List[str]): """Process divcal command""" parser = argparse.ArgumentParser( add_help=False, formatter_class=argparse.ArgumentDefaultsHelpFormatter, prog="divcal", description="""Get dividend calendar for selected date""", ) parser.add_argument( "-d", "--date", default=datetime.now(), type=valid_date, dest="date", help="Date to get format for", ) parser.add_argument( "-s", "--sort", default=["Dividend"], nargs="+", type=str, help="Column to sort by", dest="sort", ) parser.add_argument( "-a", "--ascend", default=False, action="store_true", help="Flag to sort in ascending order", dest="ascend", ) if other_args and "-" not in other_args[0][0]: other_args.insert(0, "-d") ns_parser = parse_known_args_and_warn( parser, other_args, export_allowed=EXPORT_ONLY_RAW_DATA_ALLOWED, limit=10) if ns_parser: sort_col = " ".join(ns_parser.sort) if sort_col not in self.dividend_columns: console.print( f"{sort_col} not a valid selection for sorting.\n") return nasdaq_view.display_dividend_calendar( ns_parser.date.strftime("%Y-%m-%d"), sort_col=sort_col, ascending=ns_parser.ascend, limit=ns_parser.limit, export=ns_parser.export, )
def test_display_dividend_calendar(mocker): mocker.patch.object(target=helper_funcs.gtff, attribute="USE_TABULATE_DF", new=False) nasdaq_view.display_dividend_calendar(date="2022-01-11", limit=2)