def test_every_currency(event_loop): async def wrapper(): async with AsyncPymarketcap(**asyncparms) as apym: show_msg = True async for currency in apym.every_currency(): if show_msg: print("Testing all responses...") show_msg = False res.append(currency) # Test types assert_types(currency) assert_consistence(currency) assert isinstance(res, list) with open(cache_file, "w") as f: f.write(json.dumps(res, ensure_ascii=False)) if os.path.exists(cache_file): with open(cache_file, "r") as f: for curr in json.loads(f.read()): res.append(curr) assert isinstance(res, list) for currency in res: assert_types(currency) assert_consistence(currency) else: event_loop.run_until_complete(wrapper())
def test_convert(): coin = choice(pym.coins) print("(Currency: %s)" % coin, end=" ") res = pym.currency(coin, convert="BTC") assert_types(res) assert_consistence(res)
def test_convert(): website_slug = random_cryptocurrency(pym)["website_slug"] print('(<currency>["website_slug"] == "%s")' % website_slug, end=" ") res = pym.currency(website_slug, convert="BTC") assert_types(res) assert_consistence(res)
async def wrapper(): async with AsyncPymarketcap(**asyncparms) as apym: show_msg = True async for currency in apym.every_currency(): if show_msg: print("Testing all responses...") show_msg = False res.append(currency) # Test types assert_types(currency) assert_consistence(currency) assert isinstance(res, list) with open(cache_file, "w") as f: f.write(json.dumps(res, ensure_ascii=False))
def test_consistence(): coin = choice(pym.coins) print("(Currency: %s)" % coin, end=" ") res = pym.currency(coin) assert_consistence(res)