async def notification_stan(event_loop, client_id): # pylint: disable=redefined-outer-name """Create a stan connection for each function, to be used in the tests.""" nats_client = Nats() stan_client = Stan() cluster_name = 'test-cluster' await nats_client.connect(io_loop=event_loop, name='entity.filing.tester') await stan_client.connect(cluster_name, client_id, nats=nats_client) yield stan_client await stan_client.close() await nats_client.close()
async def stan(event_loop, client_id): """Create a stan connection for each function, to be used in the tests.""" nc = Nats() sc = Stan() cluster_name = 'test-cluster' await nc.connect(io_loop=event_loop, name='entity.filing.tester') await sc.connect(cluster_name, client_id, nats=nc) yield sc await sc.close() await nc.close()
async def test_queue_connection(stan_server, event_loop, client_id): """Assert that we connect to the queue configuration used by the tests.""" nc = Nats() await nc.connect(loop=event_loop) sc = Stan() await sc.connect('test-cluster', client_id, nats=nc) assert sc._pub_prefix # pylint: disable=protected-access; sc does not expose a connection check assert sc._conn_id # pylint: disable=protected-access; sc does not expose a connection check await sc.close() # should not close the connection assert nc.is_connected with pytest.raises(StanError): await sc.close() await nc.close() assert not nc.is_connected
async def entity_stan(app, event_loop, client_id): """Create a stan connection for each function. Uses environment variables for the cluster name. """ nc = Nats() sc = Stan() await nc.connect(io_loop=event_loop) cluster_name = os.getenv('STAN_CLUSTER_NAME') if not cluster_name: raise ValueError('Missing env variable: STAN_CLUSTER_NAME') await sc.connect(cluster_name, client_id, nats=nc) yield sc await sc.close() await nc.close()