def call_valuation(self, other_args: List[str]):
        """Process valuation command"""
        parser = argparse.ArgumentParser(
            add_help=False,
            formatter_class=argparse.ArgumentDefaultsHelpFormatter,
            prog="valuation",
            description="""
                View group (sectors, industry or country) valuation data. [Source: Finviz]
            """,
        )
        parser.add_argument(
            "-g",
            "--group",
            type=str,
            default="sector",
            nargs="+",
            dest="group",
            help="Data group (sector, industry or country)",
        )
        parser.add_argument(
            "-s",
            "--sortby",
            dest="sort_col",
            type=str,
            choices=self.valuation_sort_cols,
            default="Name",
            help="Column to sort by",
        )
        parser.add_argument(
            "-a",
            "-ascend",
            dest="ascend",
            help="Flag to sort in ascending order",
            action="store_true",
            default=False,
        )
        if other_args and "-" not in other_args[0][0]:
            other_args.insert(0, "-g")

        ns_parser = parse_known_args_and_warn(
            parser, other_args, export_allowed=EXPORT_ONLY_RAW_DATA_ALLOWED)
        if ns_parser:
            group = (" ".join(ns_parser.group) if isinstance(
                ns_parser.group, list) else ns_parser.group)
            finviz_view.display_valuation(
                s_group=self.d_GROUPS[group],
                sort_col=ns_parser.sort_col,
                ascending=ns_parser.ascend,
                export=ns_parser.export,
            )
示例#2
0
def test_display_valuation(mocker, tab):
    # MOCK GTFF
    mocker.patch.object(target=helper_funcs.gtff,
                        attribute="USE_TABULATE_DF",
                        new=tab)
    mocker.patch.object(target=helper_funcs.gtff,
                        attribute="USE_ION",
                        new=True)

    # MOCK EXPORT_DATA
    mocker.patch(target="gamestonk_terminal.economy.finviz_view.export_data")

    finviz_view.display_valuation(
        s_group="Sector",
        sort_col="Name",
        ascending=True,
        export="",
    )