Skip to content

Commit

Permalink
fix test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
djeck1432 committed Nov 28, 2024
1 parent 5f7f6d3 commit a887533
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dashboard_app_ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
- name: Create Test Database
run: |
PGPASSWORD=postgres psql -h 127.0.0.1 -p 5432 -U postgres -c "CREATE DATABASE dashboard_app;"
PGPASSWORD=postgres psql -h 127.0.0.1 -p 5432 -U postgres -c "CREATE DATABASE data_handler;"
- name: Run Tests for Dashboard_App
working-directory: ./apps/dashboard_app
Expand Down
12 changes: 6 additions & 6 deletions apps/dashboard_app/helpers/load_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from dashboard_app.helpers.tools import get_prices

logger = logging.getLogger(__name__)
data_connector = DataConnector()



class DashboardDataHandler:
Expand All @@ -31,6 +31,7 @@ def __init__(self):
"""
Initialize the data handler.
"""
self.data_connector = DataConnector()
self.underlying_addresses_to_decimals = defaultdict(dict)
self.zklend_state = self._init_zklend_state()
self.prices = None
Expand All @@ -41,8 +42,7 @@ def __init__(self):
# nostra_mainnet_state,
]

@staticmethod
def _init_zklend_state() -> ZkLendState:
def _init_zklend_state(self) -> ZkLendState:
"""
Initialize ZkLend state.
Fetch data from the database and initialize the state.
Expand All @@ -51,9 +51,9 @@ def _init_zklend_state() -> ZkLendState:
logger.info("Initializing ZkLend state.")
zklend_state = ZkLendState()
start = monotonic()
zklend_data = data_connector.fetch_data(data_connector.ZKLEND_SQL_QUERY)
zklend_interest_rate_data = data_connector.fetch_data(
data_connector.ZKLEND_INTEREST_RATE_SQL_QUERY
zklend_data = self.data_connector.fetch_data(self.data_connector.ZKLEND_SQL_QUERY)
zklend_interest_rate_data = self.data_connector.fetch_data(
self.data_connector.ZKLEND_INTEREST_RATE_SQL_QUERY
)

zklend_data_dict = zklend_data.to_dict(orient="records")
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard_app/tests/test_dashboard_data_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
@pytest.fixture
def mock_data_connector():
"""Fixture to mock the DataConnector."""
with patch("dashboard_app.helpers.load_data.data_connector") as MockConnector:
with patch("dashboard_app.helpers.load_data.DataConnector") as MockConnector:
connector = MockConnector
# Mocking fetch_data calls with dummy data
connector.fetch_data.side_effect = [
Expand Down

0 comments on commit a887533

Please sign in to comment.