def test_display_options(mocker, toggle):
    # MOCK CHARTS
    mocker.patch.object(
        target=helper_funcs.gtff,
        attribute="USE_TABULATE_DF",
        new=toggle,
    )

    # MOCK EXPORT_DATA
    mocker.patch(
        target="gamestonk_terminal.stocks.options.fdscanner_view.export_data",
    )

    fdscanner_view.display_options(
        num=5,
        sort_column=["Vol"],
        export="csv",
        ascending=True,
        calls_only=toggle,
        puts_only=not toggle,
    )

    fdscanner_view.export_data.assert_called_once()
Ejemplo n.º 2
0
 def call_unu(self, other_args: List[str]):
     """Process act command"""
     parser = argparse.ArgumentParser(
         prog="unu",
         add_help=False,
         formatter_class=argparse.ArgumentDefaultsHelpFormatter,
         description="This command gets unusual options from fdscanner.com",
     )
     parser.add_argument(
         "-l",
         "--limit",
         dest="limit",
         type=int,
         default=20,
         help=
         "Limit of options to show. Each scraped page gives 20 results.",
     )
     parser.add_argument(
         "-s",
         "--sortby",
         dest="sortby",
         nargs="+",
         default="Vol/OI",
         choices=self.unu_sortby_choices,
         help=
         "Column to sort by.  Vol/OI is the default and typical variable to be considered unusual.",
     )
     parser.add_argument(
         "-a",
         "--ascending",
         dest="ascend",
         default=False,
         action="store_true",
         help="Flag to sort in ascending order",
     )
     parser.add_argument(
         "-p",
         "--puts_only",
         dest="puts_only",
         help="Flag to show puts only",
         default=False,
         action="store_true",
     )
     parser.add_argument(
         "-c",
         "--calls_only",
         dest="calls_only",
         help="Flag to show calls only",
         default=False,
         action="store_true",
     )
     if other_args and "-" not in other_args[0][0]:
         other_args.insert(0, "-l")
     ns_parser = parse_known_args_and_warn(parser, other_args,
                                           EXPORT_ONLY_RAW_DATA_ALLOWED)
     if ns_parser:
         if ns_parser.calls_only and ns_parser.puts_only:
             print(
                 "Cannot return puts only and calls only. Either use one or neither\n."
             )
         else:
             fdscanner_view.display_options(
                 num=ns_parser.limit,
                 sort_column=ns_parser.sortby,
                 export=ns_parser.export,
                 ascending=ns_parser.ascend,
                 calls_only=ns_parser.calls_only,
                 puts_only=ns_parser.puts_only,
             )