feat: add environment variables and docs
ref: N25B-352
This commit is contained in:
32
test/integration/test_config.py
Normal file
32
test/integration/test_config.py
Normal file
@@ -0,0 +1,32 @@
|
||||
from mock import patch, mock
|
||||
|
||||
from robot_interface.core.config import Settings
|
||||
from robot_interface.endpoints.main_receiver import MainReceiver
|
||||
|
||||
|
||||
def test_environment_variables(monkeypatch):
|
||||
"""
|
||||
When environment variables are set, creating settings should use these.
|
||||
"""
|
||||
monkeypatch.setenv("AGENT__CONTROL_BACKEND_HOST", "some_value_that_should_be_different")
|
||||
|
||||
settings = Settings()
|
||||
|
||||
assert settings.agent_settings.control_backend_host == "some_value_that_should_be_different"
|
||||
|
||||
|
||||
@patch("robot_interface.endpoints.main_receiver.settings")
|
||||
@patch("robot_interface.endpoints.socket_base.settings")
|
||||
def test_create_endpoint_custom_host(base_settings, main_settings):
|
||||
"""
|
||||
When a custom host is given in the settings, check that an endpoint's socket connects to it.
|
||||
"""
|
||||
fake_context = mock.Mock()
|
||||
fake_socket = mock.Mock()
|
||||
fake_context.socket.return_value = fake_socket
|
||||
base_settings.agent_settings.control_backend_host = "not_localhost"
|
||||
main_settings.agent_settings.main_receiver_port = 9999
|
||||
|
||||
_ = MainReceiver(fake_context)
|
||||
|
||||
fake_socket.connect.assert_called_once_with("tcp://not_localhost:9999")
|
||||
Reference in New Issue
Block a user