def publish_agent(request, volttron_instances, forwarder): global volttron_instance1, volttron_instance2 #print "Fixture publish_agent" # 1: Start a fake agent to publish to message bus if request.param == 'volttron_2': agent = PublishMixin(volttron_instance1.opts['publish_address']) else: agent = volttron_instance1.build_agent(identity='test-agent') # 2: add a tear down method to stop sqlhistorian agent and the fake # agent that published to message bus def stop_agent(): print("In teardown method of publish_agent") if isinstance(agent, Agent): agent.core.stop() request.addfinalizer(stop_agent) return agent
def publish_agent(request, volttron_instance): # 1: Start a fake agent to publish to message bus print("**In setup of publish_agent volttron is_running {}".format( volttron_instance.is_running)) agent = None if sqlite_platform == 'volttron_2': if agent is None or not isinstance(agent, PublishMixin): agent = PublishMixin(volttron_instance.opts['publish_address']) else: if agent is None or isinstance(agent, PublishMixin): agent = volttron_instance.build_agent() # 2: add a tear down method to stop the fake # agent that published to message bus def stop_agent(): print("In teardown method of publish_agent") if isinstance(agent, Agent): agent.core.stop() request.addfinalizer(stop_agent) return agent