def setUp(self):
        temp_file = os.path.join(Path.home(), ".temp_coinmarketcap.json")
        keys_file = os.path.join(Path.home(), ".coinmarketcap.json")
        sand_env = os.environ["COINMARKETCAP_SANDBOX"]
        prod_env = os.environ["COINMARKETCAP_PRODUCTION"]

        # Test no keys
        os.rename(keys_file, temp_file)
        del os.environ["COINMARKETCAP_SANDBOX"]
        del os.environ["COINMARKETCAP_PRODUCTION"]
        with self.assertRaises(KeyError):
            production = coinmarketcap.Client()
        with self.assertRaises(KeyError):
            sandbox = coinmarketcap.Client(sandbox=True)

        # Test os env
        os.environ["COINMARKETCAP_SANDBOX"] = sand_env
        os.environ["COINMARKETCAP_PRODUCTION"] = prod_env
        production = coinmarketcap.Client()
        sandbox = coinmarketcap.Client(sandbox=True)
        self.assertIsInstance(production, coinmarketcap.client.Production)
        self.assertIsInstance(sandbox, coinmarketcap.client.Sandbox)

        # Test file
        os.rename(temp_file, keys_file)
        production = coinmarketcap.Client()
        sandbox = coinmarketcap.Client(sandbox=True)
        self.assertIsInstance(production, coinmarketcap.client.Production)
        self.assertIsInstance(sandbox, coinmarketcap.client.Sandbox)

        # Test key
        self.production = coinmarketcap.Client(apikey=prod_env)
        self.sandbox = coinmarketcap.Client(apikey=sand_env, sandbox=True)
        self.assertIsInstance(production, coinmarketcap.client.Production)
        self.assertIsInstance(sandbox, coinmarketcap.client.Sandbox)
示例#2
0
 def setUp(self):
     self.sandbox = coinmarketcap.Client(sandbox=True).cryptocurrency
示例#3
0
 def setUp(self):
     self.sandbox = coinmarketcap.Client(sandbox=True).tools
示例#4
0
 def setUp(self):
     self.sandbox = coinmarketcap.Client(sandbox=True).global_metrics