コード例 #1
0
ファイル: test_scraper.py プロジェクト: panchorifa/marketcap
def test_scrape_market_with_default_limit():
    market = MarketScraper(MARKET_TEXT).scrape_market()
    assert (len(market.coins) == 11)
    btc = market.coins[0]
    assert int(btc.rank) == 1
    assert btc.symbol == 'BTC'
    assert btc.name == 'Bitcoin'
    assert btc.price == '$9,701.35'
    assert btc.cap == '$178,487,831,257'
    assert btc.volume == '$24,160,676,973'
    assert btc.supply == '18,398,250'
    assert btc.percent1h == '-0.37%'
    assert btc.percent24h == '2.11%'
    assert btc.percent7d == '1.46%'

    coins = market.coins
    assert coins[1].symbol == 'ETH'
    assert coins[2].symbol == 'USDT'
    assert coins[3].symbol == 'XRP'
    assert coins[4].symbol == 'BCH'
    assert coins[5].symbol == 'BSV'
    assert coins[6].symbol == 'LTC'
    assert coins[7].symbol == 'BNB'
    assert coins[8].symbol == 'EOS'
    assert coins[9].symbol == 'ADA'
    assert coins[10].symbol == 'XTZ'
コード例 #2
0
ファイル: test_scraper.py プロジェクト: panchorifa/marketcap
def test_scrape_coin():
    coin = MarketScraper(COIN_TEXT).scrape_coin()
    assert coin.symbol == 'BTC'
    assert coin.name == 'Bitcoin'
    assert coin.rank == '1'
    assert coin.cap == '$169,591,156,093'
    assert coin.price == '$9503.61'
    assert coin.supply == '17,844,912'
    assert coin.volume == '$14,795,854,714'
コード例 #3
0
ファイル: test_scraper.py プロジェクト: pir8aye/marketcap
def test_parser():
    market = MarketScraper(text).scrape()
    assert (len(market.coins) == 953)
    coin = market.coins[0]
    assert (int(coin.rank) == 1)
    assert (
        coin.icon ==
        'https://files.coinmarketcap.com/static/img/coins/16x16/bitcoin.png')
    assert (coin.symbol == 'BTC')
    assert (coin.name == 'Bitcoin')
    assert (coin.price == '$2499.55')
    assert (coin.cap == '$41,077,509,717')
    assert (coin.volume == '$909,999,000')
    assert (coin.supply == '16,433,962')
    assert (coin.percent1h == '-0.59%')
    assert (coin.percent24h == '-3.91%')
    assert (coin.percent7d == '0.98%')

    coins = market.coins
    assert (coins[9].symbol == 'STRAT')
    assert (coins[10].symbol == 'EOS')
コード例 #4
0
 def coin(self, name):
     """ Returns single coin """
     text = _get_url_content(COIN_URL.format(coin=name))
     return MarketScraper(text).scrape_coin()
コード例 #5
0
 def market(self, limit=DEFAULT_COINS_LIMIT):
     """ Returns all coins """
     text = _get_url_content(MARKET_URL)
     return MarketScraper(text).scrape_market(limit)
コード例 #6
0
ファイル: test_scraper.py プロジェクト: pir8aye/marketcap
def test_limit():
    market = MarketScraper(text).scrape(5)
    assert (len(market.coins) == 5)
コード例 #7
0
ファイル: test_scraper.py プロジェクト: panchorifa/marketcap
def test_scrape_market_with_limit():
    market = MarketScraper(MARKET_TEXT).scrape_market(2)
    assert len(market.coins) == 2
コード例 #8
0
ファイル: test_scraper.py プロジェクト: panchorifa/marketcap
def test_scrape_market_with_invalid_limit():
    market = MarketScraper(MARKET_TEXT).scrape_market(-1)
    assert market.coins == []