Skip to content

Commit

Permalink
Save was not async
Browse files Browse the repository at this point in the history
  • Loading branch information
bh2smith committed Dec 26, 2024
1 parent 373ba4e commit 7d4dfae
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tests/unit/job_test.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import unittest
from unittest.mock import AsyncMock, patch
from unittest.mock import AsyncMock, Mock, patch

from pandas import DataFrame
import pytest
from dune_client.query import QueryBase

from src.destinations.postgres import PostgresDestination
from src.interfaces import TypedDataFrame
from src.job import Database, Job
from src.sources.dune import DuneSource

Expand Down Expand Up @@ -36,8 +38,11 @@ async def test_metrics_collection(self, mock_metrics_push, *_):
db_url="postgresql://postgres:postgres@localhost:5432/postgres",
table_name="some_table",
)
src.fetch = AsyncMock()
dest.save = AsyncMock()

# Create mock DataFrame with explicit is_empty return value
test_df = TypedDataFrame(DataFrame({"col1": [1, 2, 3], "col2": ["a", "b", "c"]}), {})
src.fetch = AsyncMock(return_value=test_df)
dest.save = Mock(return_value=3)
test_job = Job(name="job name", source=src, destination=dest)

with patch("src.metrics.env", return_value=None):
Expand Down

0 comments on commit 7d4dfae

Please sign in to comment.