Implement workflows for fake data generation, scouter processing, and core scouter operations - Added `FakeData` workflow to generate random data and send it to a Kafka topic. - Implemented `Scouter` workflow to load data from Kafka and trigger the core scouter workflow. - Created `CoreScouter` workflow to process data through quality gates, aggregation, and export to PostgreSQL. - Developed comprehensive unit tests for activities and workflows, ensuring proper functionality and error handling. - Enhanced Redis and Postgres activities with robust testing for data handling and error notifications. - Introduced quality filters for data validation and implemented tests to verify their functionality.
30 lines
744 B
Python
30 lines
744 B
Python
from unittest.mock import AsyncMock, patch, ANY
|
|
from pytest import fixture, mark
|
|
from scouter.workflow.fake_data import FakeData
|
|
from scouter.activities.faker import Faker
|
|
|
|
|
|
@fixture
|
|
def fake_data():
|
|
return FakeData()
|
|
|
|
|
|
@mark.asyncio
|
|
@patch('scouter.workflow.fake_data.workflow', new_callable=AsyncMock)
|
|
async def test_fake_data_workflow(mock_workflow, fake_data):
|
|
mock_workflow.execute_activity_method.return_value = None
|
|
await fake_data.run(
|
|
{
|
|
'topic': 'test_topic'
|
|
}
|
|
)
|
|
|
|
mock_workflow.execute_activity_method.assert_called_once_with(
|
|
Faker.generate_and_send_data,
|
|
{
|
|
'topic': 'test_topic'
|
|
},
|
|
retry_policy=ANY,
|
|
start_to_close_timeout=ANY
|
|
)
|