def test_emit_event():
    count = 0

    sub = Subscription(stream_id, stream_partition, 'api_key',
                       lambda: print('done'))

    def test():
        nonlocal count
        count += 1

    sub.on(EventConstant.SUBSCRIBED, test)

    sub.set_state(EventConstant.SUBSCRIBED)

    assert count == 1
def test_update_state():

    sub = Subscription(stream_id, stream_partition, 'api_key',
                       lambda: print('done'))
    sub.set_state(EventConstant.SUBSCRIBED)
    assert sub.get_state() == EventConstant.SUBSCRIBED