def test_receive_with_flow_control(publisher_client, topic, subscription_async, capsys): _publish_messages(publisher_client, topic) subscriber.receive_messages_with_flow_control(PROJECT_ID, SUBSCRIPTION_ASYNC, 5) out, _ = capsys.readouterr() assert "Listening" in out assert subscription_async in out assert "message" in out
def test_receive_synchronously(publisher_client, topic, subscription, capsys): _publish_messages(publisher_client, topic) with _make_sleep_patch(): with pytest.raises(RuntimeError, match='sigil'): subscriber.receive_messages_with_flow_control( PROJECT, SUBSCRIPTION) out, _ = capsys.readouterr() assert 'Message 1' in out assert 'Message 2' in out assert 'Message 3' in out
def test_receive_with_flow_control( publisher_client, topic, subscription, capsys): _publish_messages(publisher_client, topic) with _make_sleep_patch(): with pytest.raises(RuntimeError, match='sigil'): subscriber.receive_messages_with_flow_control( PROJECT, SUBSCRIPTION) out, _ = capsys.readouterr() assert 'Listening' in out assert subscription in out assert 'Message 1' in out