Code import - branch feature/SIENTIAPDE-1646
This commit is contained in:
42
tests/utils/test_connectors_config.py
Normal file
42
tests/utils/test_connectors_config.py
Normal file
@@ -0,0 +1,42 @@
|
||||
import os
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
|
||||
from scouter.utils.connectors_config import (
|
||||
build_kafka_config,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_env_vars():
|
||||
with patch.dict(os.environ, {}, clear=True):
|
||||
yield
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('mock_env_vars')
|
||||
def test_build_kafka_config_defaults():
|
||||
"""Test that build_kafka_config returns default values when no env vars are set"""
|
||||
config = build_kafka_config()
|
||||
|
||||
assert config == {
|
||||
'bootstrap_servers': 'localhost:9092',
|
||||
'polling_time': 1000,
|
||||
'group_id': 'scouter-group',
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.usefixtures('mock_env_vars')
|
||||
def test_build_kafka_config_with_env_vars():
|
||||
"""Test that build_kafka_config uses env vars when set"""
|
||||
with patch.dict(
|
||||
os.environ,
|
||||
{'KAFKA_BOOTSTRAP_SERVERS': 'kafka.example.com:9092', 'KAFKA_POLLING_TIME': '5000'},
|
||||
):
|
||||
config = build_kafka_config()
|
||||
|
||||
assert config == {
|
||||
'bootstrap_servers': 'kafka.example.com:9092',
|
||||
'polling_time': 5000,
|
||||
'group_id': 'scouter-group',
|
||||
}
|
||||
Reference in New Issue
Block a user