def test_display_cmc_top_coins(mocker): # MOCK EXPORT_DATA mocker.patch( target= "gamestonk_terminal.cryptocurrency.discovery.coinmarketcap_view.export_data" ) coinmarketcap_view.display_cmc_top_coins()
def test_display_cmc_top_coins_empty_df(mocker): view_path = "gamestonk_terminal.cryptocurrency.discovery.coinmarketcap_view" # MOCK GET_SEARCH_RESULTS mocker.patch( target=f"{view_path}.coinmarketcap_model.get_cmc_top_n", return_value=pd.DataFrame(), ) coinmarketcap_view.display_cmc_top_coins()
def call_cmctop(self, other_args): """Process cmctop command""" parser = argparse.ArgumentParser( prog="cmctop", add_help=False, formatter_class=argparse.ArgumentDefaultsHelpFormatter, description="This gets the top ranked coins from coinmarketcap.com", ) parser.add_argument( "-l", "--limit", default=15, dest="limit", help="Limit of records", type=check_positive, ) parser.add_argument( "-s", "--sort", dest="sortby", type=str, help="column to sort data by.", default="CMC_Rank", choices=coinmarketcap_model.FILTERS, ) parser.add_argument( "--descend", action="store_false", help="Flag to sort in descending order (lowest first)", dest="descend", default=True, ) ns_parser = parse_known_args_and_warn( parser, other_args, EXPORT_ONLY_RAW_DATA_ALLOWED ) if ns_parser: coinmarketcap_view.display_cmc_top_coins( top=ns_parser.limit, sortby=ns_parser.sortby, descend=ns_parser.descend, export=ns_parser.export, )
def call_cmctop(self, other_args): """Process cmctop command""" parser = argparse.ArgumentParser( prog="cmctop", add_help=False, formatter_class=argparse.ArgumentDefaultsHelpFormatter, description="This gets the top ranked coins from coinmarketcap.com", ) parser.add_argument( "-t", "--top", default=15, dest="top", help="Limit of records", type=check_positive, ) parser.add_argument( "-s", "--sort", dest="sortby", type=str, help="column to sort data by.", default="CMC_Rank", choices=[ "Symbol", "CMC_Rank", "LastPrice", "DayPctChange", "MarketCap" ], ) parser.add_argument( "--descend", action="store_false", help="Flag to sort in descending order (lowest first)", dest="descend", default=True, ) parser.add_argument( "--export", choices=["csv", "json", "xlsx"], default="", type=str, dest="export", help="Export dataframe data to csv,json,xlsx file", ) try: ns_parser = parse_known_args_and_warn(parser, other_args) if not ns_parser: return coinmarketcap_view.display_cmc_top_coins( top=ns_parser.top, sortby=ns_parser.sortby, descend=ns_parser.descend, export=ns_parser.export, ) except Exception as e: print(e, "\n")