diff --git a/src/blockwatch/tzpro_api_constants.py b/src/blockwatch/tzpro_api_constants.py index 0a605490..16cc759e 100644 --- a/src/blockwatch/tzpro_api_constants.py +++ b/src/blockwatch/tzpro_api_constants.py @@ -1,3 +1,7 @@ +import os +from dotenv import load_dotenv +from log_config import verbose_logger + # TODO: Check if there are changes to the indicies! # https://docs.tzpro.io/api/index/tables/income-table @@ -36,3 +40,11 @@ idx_cb_delegator_id = 0 idx_cb_current_balance = 1 idx_cb_delegator_address = 2 + +def load_key_from_env_variables(): + load_dotenv() + try: + key = os.getenv("TZPRO_API_KEY") + except: + verbose_logger.exception("Unable to load TZPRO_API_KEY from .env file!") + return key diff --git a/src/blockwatch/tzpro_block_api.py b/src/blockwatch/tzpro_block_api.py index d8cbfc83..1a150e1d 100644 --- a/src/blockwatch/tzpro_block_api.py +++ b/src/blockwatch/tzpro_block_api.py @@ -3,7 +3,7 @@ from exception.api_provider import ApiProviderException from log_config import main_logger, verbose_logger from Constants import TZPRO_API_URL -from tzpro_reward_api import load_key_from_env_variables +from src.blockwatch.tzpro_api_constants import load_key_from_env_variables logger = main_logger diff --git a/src/blockwatch/tzpro_reward_api.py b/src/blockwatch/tzpro_reward_api.py index dee7f2ff..c6498961 100644 --- a/src/blockwatch/tzpro_reward_api.py +++ b/src/blockwatch/tzpro_reward_api.py @@ -1,27 +1,16 @@ -import os -from dotenv import load_dotenv - from api.reward_api import RewardApi import math -from log_config import main_logger, verbose_logger +from log_config import main_logger from model.reward_provider_model import RewardProviderModel from src.blockwatch.tzpro_reward_provider_helper import TzProRewardProviderHelper +from src.blockwatch.tzpro_api_constants import load_key_from_env_variables from Constants import MUTEZ_PER_TEZ from Dexter import dexter_utils as dxtz logger = main_logger -def load_key_from_env_variables(): - load_dotenv() - try: - key = os.getenv("TZPRO_API_KEY") - except: - verbose_logger.exception("Unable to load TZPRO_API_KEY from .env file!") - return key - - class TzProRewardApiImpl(RewardApi): def __init__(self, nw, baking_address): super().__init__() diff --git a/tests/integration/test_api_consistency.py b/tests/integration/test_api_consistency.py index 99d17e29..762a74a8 100644 --- a/tests/integration/test_api_consistency.py +++ b/tests/integration/test_api_consistency.py @@ -3,8 +3,6 @@ from src.Constants import DEFAULT_NETWORK_CONFIG_MAP, PUBLIC_NODE_URL, RewardsType from tests.utils import Constants -from src.blockwatch.tzpro_reward_api import load_key_from_env_variables - # Block APIs from src.tzkt.tzkt_block_api import TzKTBlockApiImpl from src.blockwatch.tzpro_block_api import TzProBlockApiImpl @@ -13,7 +11,7 @@ # Reward APIs from src.tzkt.tzkt_reward_api import TzKTRewardApiImpl from src.blockwatch.tzpro_reward_api import TzProRewardApiImpl -from src.rpc.rpc_reward_api import RpcRewardApiImpl +from src.blockwatch.tzpro_api_constants import load_key_from_env_variables MAINNET_ADDRESS_DELEGATOR = Constants.MAINNET_ADDRESS_DELEGATOR MAINNET_ADDRESS_STAKENOW_BAKER = Constants.MAINNET_ADDRESS_STAKENOW_BAKER diff --git a/src/test_verbose_logging_helper.py b/tests/regression/test_verbose_logging_helper.py similarity index 98% rename from src/test_verbose_logging_helper.py rename to tests/regression/test_verbose_logging_helper.py index db1cee4e..78eb492e 100644 --- a/src/test_verbose_logging_helper.py +++ b/tests/regression/test_verbose_logging_helper.py @@ -1,8 +1,8 @@ import shutil from unittest import TestCase -from log_config import FORMATTER -from verbose_logging_helper import VerboseLoggingHelper +from src.log_config import FORMATTER +from src.verbose_logging_helper import VerboseLoggingHelper import logging import os