示例#1
0
def test_economy_calendar_events_empty(mocker):
    # MOCK GET_ECONOMY_CALENDAR_EVENTS
    attrs = {"empty": True}
    mock_empty_df = mocker.Mock(**attrs)
    mocker.patch(
        target="gamestonk_terminal.economy.finnhub_view.finnhub_model.get_economy_calendar_events",
        new=mock_empty_df,
    )

    finnhub_view.economy_calendar_events(
        country="MOCK_COUNTRY",
        num=1,
        impact="MOCK_IMPACT",
        export="",
    )
示例#2
0
def test_economy_calendar_events_no_impact(mocker):
    # MOCK GET
    attrs = {
        "status_code": 200,
        "json.return_value": MOCK_ECONOMY_CALENDAR_EVENTS_DICT,
    }
    mock_response = mocker.Mock(**attrs)
    mocker.patch(target="requests.get", new=mocker.Mock(return_value=mock_response))

    finnhub_view.economy_calendar_events(
        country="AU",
        num=1,
        impact="MOCK_IMPACT",
        export="",
    )
    def call_events(self, other_args: List[str]):
        """Process events command"""
        parser = argparse.ArgumentParser(
            add_help=False,
            formatter_class=argparse.ArgumentDefaultsHelpFormatter,
            prog="events",
            description="""
                Output economy impact calendar impact events. [Source: Finnhub]
            """,
        )
        parser.add_argument(
            "-c",
            "--country",
            action="store",
            dest="country",
            type=str,
            default="US",
            choices=[
                "NZ", "AU", "ERL", "CA", "EU", "US", "JP", "CN", "GB", "CH"
            ],
            help="Country from where to get economy calendar impact events",
        )
        parser.add_argument(
            "-n",
            "--num",
            action="store",
            dest="num",
            type=check_positive,
            default=10,
            help="Number economy calendar impact events to display",
        )
        parser.add_argument(
            "-i",
            "--impact",
            action="store",
            dest="impact",
            type=str,
            default="all",
            choices=["low", "medium", "high", "all"],
            help="Impact of the economy event",
        )
        parser.add_argument(
            "--export",
            choices=["csv", "json", "xlsx"],
            default="",
            type=str,
            dest="export",
            help="Export dataframe data to csv,json,xlsx file",
        )
        try:
            if other_args:
                if "-" not in other_args[0]:
                    other_args.insert(0, "-c")

            ns_parser = parse_known_args_and_warn(parser, other_args)
            if not ns_parser:
                return

            finnhub_view.economy_calendar_events(
                country=ns_parser.country,
                num=ns_parser.num,
                impact=ns_parser.impact,
                export=ns_parser.export,
            )

        except Exception as e:
            print(e, "\n")
 def call_events(self, other_args: List[str]):
     """Process events command"""
     finnhub_view.economy_calendar_events(other_args)