SIENTIAPDE-1445
Enhance Activities and API Integration - Updated Activities class to include API operations for external data ingestion. - Added API configuration builder to connectors_config.py for environment variable management. - Integrated API configuration into worker setup. - Expanded unit tests to cover new API functionality and configuration handling. - Updated requirements.txt to include pycurl and prometheus-client for enhanced metrics support.
This commit is contained in:
@@ -4,6 +4,7 @@ from unittest.mock import patch
|
||||
import pytest
|
||||
|
||||
from scouter.utils.connectors_config import (
|
||||
build_api_config,
|
||||
build_druid_config,
|
||||
build_kafka_config,
|
||||
build_mongodb_config,
|
||||
@@ -154,6 +155,38 @@ def test_build_mongodb_config_with_env_vars():
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('mock_env_vars')
|
||||
def test_build_api_config_defaults():
|
||||
"""Test that build_api_config returns default values when no env vars are set"""
|
||||
config = build_api_config()
|
||||
|
||||
assert config == {
|
||||
'base_url': 'https://pi.example.com',
|
||||
'auth_type': 'basic',
|
||||
'auth_token': None,
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('mock_env_vars')
|
||||
def test_build_api_config_with_env_vars():
|
||||
"""Test that build_api_config uses env vars when set"""
|
||||
with patch.dict(
|
||||
os.environ,
|
||||
{
|
||||
'API_BASE_URL': 'https://api.production.com',
|
||||
'API_AUTH_TYPE': 'bearer',
|
||||
'API_AUTH_TOKEN': 'secret_token_123',
|
||||
},
|
||||
):
|
||||
config = build_api_config()
|
||||
|
||||
assert config == {
|
||||
'base_url': 'https://api.production.com',
|
||||
'auth_type': 'bearer',
|
||||
'auth_token': 'secret_token_123',
|
||||
}
|
||||
|
||||
|
||||
def test_build_druid_config_defaults():
|
||||
"""Test that build_druid_config returns default values when no env vars are set"""
|
||||
config = build_druid_config()
|
||||
|
||||
Reference in New Issue
Block a user