SIENTIAPDE-1110
Enhance Gates and Redis activities by adding metadata parameter to apply_aggregation and notification methods. Refactor notification handling to use send_notification for improved consistency. Update tests to reflect changes in notification method calls and ensure proper functionality with new metadata integration.
This commit is contained in:
@@ -2,6 +2,8 @@ import os
|
||||
from unittest.mock import patch
|
||||
import pytest
|
||||
from scouter.utils.connectors_config import (
|
||||
build_druid_config,
|
||||
build_mongodb_config,
|
||||
build_postgres_config,
|
||||
build_kafka_config,
|
||||
build_redis_config
|
||||
@@ -113,3 +115,53 @@ def test_build_redis_config_with_env_vars():
|
||||
'username': 'test',
|
||||
'password': 'test'
|
||||
}
|
||||
|
||||
|
||||
def test_build_mongodb_config_defaults():
|
||||
"""Test that build_mongodb_config returns default values when no env vars are set"""
|
||||
config = build_mongodb_config()
|
||||
|
||||
assert config == {
|
||||
'connection_string': 'mongodb://sientia:sientia@localhost:27017', # NOSONAR
|
||||
'database_name': 'sientia'
|
||||
}
|
||||
|
||||
|
||||
def test_build_mongodb_config_with_env_vars():
|
||||
"""Test that build_mongodb_config uses env vars when set"""
|
||||
with patch.dict(os.environ, {
|
||||
'MONGODB_URL': 'mongodb.example.com:27017',
|
||||
'MONGODB_DATABASE_NAME': 'test_db',
|
||||
'MONGODB_USERNAME': 'test',
|
||||
'MONGODB_PASSWORD': 'test'
|
||||
}):
|
||||
config = build_mongodb_config()
|
||||
|
||||
assert config == {
|
||||
'connection_string': 'mongodb://test:test@mongodb.example.com:27017',
|
||||
'database_name': 'test_db'
|
||||
}
|
||||
|
||||
|
||||
def test_build_druid_config_defaults():
|
||||
"""Test that build_druid_config returns default values when no env vars are set"""
|
||||
config = build_druid_config()
|
||||
|
||||
assert config == {
|
||||
'host': 'localhost',
|
||||
'port': 8082
|
||||
}
|
||||
|
||||
|
||||
def test_build_druid_config_with_env_vars():
|
||||
"""Test that build_druid_config uses env vars when set"""
|
||||
with patch.dict(os.environ, {
|
||||
'DRUID_HOST': 'druid.example.com',
|
||||
'DRUID_PORT': '8083'
|
||||
}):
|
||||
config = build_druid_config()
|
||||
|
||||
assert config == {
|
||||
'host': 'druid.example.com',
|
||||
'port': 8083
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user