Skip to content

Commit

Permalink
FIX bug in ETL testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
Francisco Silva authored and Francisco Silva committed Nov 18, 2024
1 parent 090611f commit db58b88
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 4 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import os
from pathlib import Path

# disable DeprecationWarning https://github.com/jupyter/jupyter_core/issues/398
os.environ["JUPYTER_PLATFORM_DIRS"] = "1"

PROJECT_DIR = Path(__file__).parents[2]
PACKAGE_DIR = PROJECT_DIR / "stocksense"
FIXTURES_DIR = Path(__file__).parent / "fixtures"
Expand Down
7 changes: 2 additions & 5 deletions tests/test_etl.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,18 @@


def test_update_index_listings(mocker, mock_stock_data, mock_active_data):
etl = ETL(config)

# mock database
mock_db = mocker.Mock()
mock_db.fetch_stock.return_value = mock_stock_data
mock_db.update_stock.return_value = True
mock_db.insert_stock.return_value = True
etl.db = mock_db
mocker.patch("stocksense.pipeline.etl.DatabaseHandler", return_value=mock_db)

# mock scraper
mocker.patch(
"stocksense.pipeline.scraper.Scraper.scrape_sp500_stock_info", return_value=mock_active_data
)

# Run update
etl = ETL(config)
etl.update_index_listings()

# verify delisted stock was updated
Expand Down

0 comments on commit db58b88

Please sign in to comment.