def test_open_config_file(mocker): # Mock open() with patch("cryptowatch.auth.open", mock_open()) as config: # Mock os.environ.get() with mock.patch.dict("os.environ", {"HOME": "/sweet/home"}): # This should open() the credential file read_config() # Forge credential file path user_home_dir = os.environ.get("HOME") filepath = "{}/.cw/credentials.yml".format(user_home_dir) # Check it was well open()'ed config.assert_called_once_with(filepath, "r")
from cryptowatch.utils import log from cryptowatch.auth import read_config from cryptowatch.requestor import Requestor from cryptowatch import stream from cryptowatch.resources.assets import Assets from cryptowatch.resources.instruments import Instruments from cryptowatch.resources.exchanges import Exchanges from cryptowatch.resources.markets import Markets # Package version __version__ = "0.0.11" sdk_version = __version__ # Try to read and set API endpoints from credential file api_key, rest_endpoint, ws_endpoint = read_config() # API default endpoints if not rest_endpoint: rest_endpoint = "https://api.cryptowat.ch" if not ws_endpoint: ws_endpoint = "wss://stream.cryptowat.ch/connect" def is_authenticated(): return api_key is not None # HTTP client default settings verify_ssl = True connect_timeout = 4 # in seconds read_timeout = 10 # in seconds