#!/usr/bin/env python3

# import sys, os
# sys.path.insert(0, os.path.abspath('..'))

import unittest
import cryptocompare



class TestCryptoCompare(unittest.TestCase):
  def assertCoinAndCurrInPrice(self, coin, curr, price):
    if isinstance(coin, list):
      for co in coin:
        self.assertCoinAndCurrInPrice(co, curr, price)
      return
    else:
      self.assertIn(coin, price)

    if isinstance(curr, list):
      for cu in curr:
        self.assertIn(cu, price[coin])
    else:
      self.assertIn(curr, price[coin])

  def test_coin_list(self):
    lst = cryptocompare.get_coin_list()
    self.assertTrue('BTC' in lst.keys())
    lst = cryptocompare.get_coin_list(True)
    self.assertTrue('BTC' in lst)

  def test_get_price(self):
    coin = 'BTC'
    price = cryptocompare.get_price(coin)
    self.assertCoinAndCurrInPrice(coin, 'EUR', price)
    price = cryptocompare.get_price(coin, curr='USD')
    self.assertCoinAndCurrInPrice(coin, 'USD', price)
    currencies = ['EUR','USD','GBP']
    price = cryptocompare.get_price(coin, curr=currencies)
    self.assertCoinAndCurrInPrice(coin, currencies, price)
    coins = ['BTC', 'XMR']
    price = cryptocompare.get_price(coins, curr=currencies)
    self.assertCoinAndCurrInPrice(coins, currencies, price)

  def test_get_price_full(self):
    price = cryptocompare.get_price('ETH', full=True)
    self.assertIn('RAW', price)
    self.assertIn('ETH', price['RAW'])
    self.assertIn('EUR', price['RAW']['ETH'])
    self.assertIn('PRICE', price['RAW']['ETH']['EUR'])


if __name__ == "__main__":
  unittest.main()
@@ -21,70 +21,8 @@
 n3%0A%0A
-# import sys, os%0A# sys.path.insert(0, os.path.abspath('..'))%0A%0A
 impo
@@ -54,17 +54,31 @@
 compare%0A
-%0A
+import datetime
 %0A%0Aclass 
@@ -1479,16 +1479,398 @@
 EUR'%5D)%0A%0A
+  def test_get_historical_price(self):%0A    coin = 'XMR'%0A    curr = 'EUR'%0A    price = cryptocompare.get_historical_price('XMR', timestamp=datetime.datetime(2017,6,6), exchange='CCCAGG')%0A    self.assertCoinAndCurrInPrice(coin, curr, price)%0A    price = cryptocompare.get_historical_price('XMR', 'EUR', datetime.datetime(2017,6,6))%0A    self.assertCoinAndCurrInPrice(coin, curr, price)%0A%0A
 %0Aif __na

Add unit test for get_historical_price