async def test_publisher(flow, scheduler, run, one_conf, port_range): """It should publish deltas when the flow starts.""" reg = flow(one_conf) schd = scheduler(reg, hold_start=False) async with run(schd): # create a subscriber subscriber = WorkflowSubscriber(schd.suite, host=schd.host, port=schd.publisher.port, topics=[b'workflow']) async with timeout(2): # wait for the first delta from the workflow btopic, msg = await subscriber.socket.recv_multipart() _, delta = process_delta_msg(btopic, msg, None) assert schd.id == delta.added.id
async def test_publisher(flow, scheduler, run, one_conf, port_range): """It should publish deltas when the flow starts.""" reg = flow(one_conf) schd = scheduler(reg, paused_start=False) async with run(schd): # create a subscriber subscriber = WorkflowSubscriber(schd.workflow, host=schd.host, port=schd.publisher.port, topics=[b'workflow']) async with timeout(2): # wait for the first delta from the workflow btopic, msg = await subscriber.socket.recv_multipart() _, delta = process_delta_msg(btopic, msg, None) for key in ('added', 'updated'): if getattr(getattr(delta, key), 'id', None): assert schd.id == getattr(delta, key).id break else: raise Exception("Delta wasn't added or updated")
def test_process_delta_msg(): """Test delta message processing.""" # test non-key not_topic, not_delta = process_delta_msg(b'foo', b'bar', None) assert not_topic == 'foo' assert not_delta == b'bar'
def msg_process(btopic, msg): self.subscriber.stopping = True self.topic, self.data = process_delta_msg(btopic, msg, None)