54 lines
1.5 KiB
Python
54 lines
1.5 KiB
Python
"""Pytest configuration and shared fixtures."""
|
|
|
|
import pytest
|
|
import pandas as pd
|
|
from unittest.mock import MagicMock, patch
|
|
import sys
|
|
from dagster import build_op_context
|
|
|
|
# Mock external dependencies that might not be available in test environment
|
|
sys.modules['spellchecker'] = MagicMock()
|
|
|
|
|
|
@pytest.fixture
|
|
def mock_context():
|
|
"""Create a mock Dagster context for testing operations."""
|
|
context = build_op_context()
|
|
return context
|
|
|
|
|
|
@pytest.fixture
|
|
def sample_dataframe():
|
|
"""Create a sample DataFrame for testing."""
|
|
return pd.DataFrame({
|
|
'Name': ['John Doe', 'jane smith', 'John Doe', 'bob johnson', 'John Doe'],
|
|
'Age': [25, 30, 25, None, 25],
|
|
'City': ['New York', 'los angeles', 'New York', 'chicago', 'New York'],
|
|
'Status': ['Active', 'INACTIVE', 'Active', 'penDing', 'Active']
|
|
})
|
|
|
|
|
|
@pytest.fixture
|
|
def sample_dataframe_with_typos():
|
|
"""Create a sample DataFrame with typos for spell checking."""
|
|
return pd.DataFrame({
|
|
'Name': ['jon doe', 'jane smith', 'bob jonson'],
|
|
'Description': ['developer', 'analst', 'enginer']
|
|
})
|
|
|
|
|
|
@pytest.fixture
|
|
def empty_dataframe():
|
|
"""Create an empty DataFrame."""
|
|
return pd.DataFrame()
|
|
|
|
|
|
@pytest.fixture
|
|
def dataframe_with_missing_values():
|
|
"""Create a DataFrame with various missing values."""
|
|
return pd.DataFrame({
|
|
'Column1': [1, None, 3, None, 5],
|
|
'Column2': ['a', 'b', None, 'd', None],
|
|
'Column3': [None, None, None, None, None]
|
|
})
|