Update README, requirements, and E2E tests for improved configuration and functionality - Enhanced the README with updated model configuration examples, including the addition of an alias for production. - Removed the `requirements-light.txt` file and updated `requirements-local.txt` and `requirements.txt` to replace `asyncua` with `opcua`. - Refactored E2E test scenarios to utilize scenario input files for better maintainability and clarity. - Improved test coverage for MinIO offload functionality and added new helper functions for loading scenario inputs. - Updated `values.yaml` to reflect new global configurations and environment variables for the laborious worker.
73 lines
2.1 KiB
Python
73 lines
2.1 KiB
Python
import os
|
|
import sys
|
|
from unittest.mock import MagicMock
|
|
|
|
from sientia_do.temporal.activities.postgres_sync import Postgres
|
|
|
|
|
|
def _noop_postgres_del(_self):
|
|
"""
|
|
Unit tests use MagicMock metrics controllers; postgres_sync.Postgres.__del__ calls
|
|
close() during GC and triggers async shutdown. Explicit ``close()`` is covered in tests.
|
|
"""
|
|
return None
|
|
|
|
|
|
Postgres.__del__ = _noop_postgres_del # type: ignore[method-assign]
|
|
|
|
# The production code converts SIENTIA_MINIO_OFFLOAD_THRESHOLD_MEGABYTES to int at import-time.
|
|
# Tests must set it to a valid integer string to avoid import errors.
|
|
os.environ.setdefault('SIENTIA_MINIO_OFFLOAD_THRESHOLD_MEGABYTES', '1')
|
|
|
|
|
|
class DummyMinioDataFramePayload:
|
|
"""
|
|
Minimal payload double used by unit tests.
|
|
|
|
The production workflow/gates expect a MinioDataFramePayload-like object with:
|
|
- async retrieve(minio_repo, workflow_metadata) -> DataFrame | dict
|
|
- has_data() -> bool
|
|
- cleanup_prefix() -> str | None
|
|
- last_timestamp: attribute
|
|
- status: attribute
|
|
"""
|
|
|
|
def __init__(
|
|
self,
|
|
*,
|
|
retrieve_return=None,
|
|
has_data: bool = True,
|
|
cleanup_prefix: str | None = None,
|
|
last_timestamp: str = '2024-01-01',
|
|
status: dict | None = None,
|
|
):
|
|
self._retrieve_return = retrieve_return
|
|
self._has_data = has_data
|
|
self._cleanup_prefix = cleanup_prefix
|
|
self.last_timestamp = last_timestamp
|
|
self.status = status
|
|
|
|
async def retrieve(self, _minio_repo, _workflow_metadata=None):
|
|
return self._retrieve_return
|
|
|
|
def has_data(self) -> bool:
|
|
return self._has_data
|
|
|
|
def cleanup_prefix(self) -> str | None:
|
|
return self._cleanup_prefix
|
|
|
|
|
|
"""
|
|
Pytest configuration file with global mocks for external dependencies.
|
|
|
|
This module mocks the 'sientia' module to avoid requiring its installation
|
|
during unit tests. The mock is registered in sys.modules before any test
|
|
imports are executed.
|
|
"""
|
|
|
|
# Mock sientia module
|
|
sientia_mock = MagicMock()
|
|
sientia_mock.ModelAnalysis = MagicMock
|
|
sys.modules['sientia'] = sientia_mock
|
|
sys.modules['sientia.ModelAnalysis'] = MagicMock()
|