def test_event_handling_no_resent():
    count = 0

    msg = create_msg()

    def test(_, __):
        nonlocal count
        count += 1

    sub = Subscription(stream_id, stream_partition, 'api_key', test)

    sub.set_resending(True)
    sub.handle_message(msg)
    assert count == 0
    sub.emit(EventConstant.NO_RESEND)
    assert count == 1
def test_handle_message_when_resending_and_is_resend_true():

    msg = create_msg()

    count = 0

    def callback(_, __):
        """
        callback function to test the number of received msg
        :param _:
        :param __:
        :return:
        """
        nonlocal count
        count += 1

    sub = Subscription(stream_id, stream_partition, 'api_key', callback)
    sub.set_resending(True)
    sub.handle_message(msg, True)
    assert (count == 1)