One potential solution is to use the volttron-testing's TestServer (from volttrontesting.server_mock import TestServer)
So that, we can do things like the following
def test_send_alert():
""" Test that an agent can send an alert through the pubsub message bus."""
# Create an agent to run the test with
# agent = Agent(identity='test-health')
agent = PlatformDriverAgent(driver_config_list=[], identity="platform.driver")
# Create the server and connect the agent with the server
ts = TestServer()
ts.connect_agent(agent=agent)
# The health.send_alert should send a pubsub message through the message bus
agent.vip.health.send_alert("my_alert", Status.build(STATUS_BAD, "no context"))
Note that without ts = TestServer(); ts.connect_agent(agent=agent) will get error like the following
One potential solution is to use the volttron-testing's TestServer (from volttrontesting.server_mock import TestServer)
So that, we can do things like the following
Note that without
ts = TestServer(); ts.connect_agent(agent=agent)
will get error like the following