

def test_10():
    channel = ('test_10-' + str(time.time()))
    message = 'Hello World'
    auth_key = ('auth-' + channel)
    pubnub.set_auth_key(auth_key)

    def _cb1(resp, ch=None):
        assert False

    def _err1(resp):
        assert (resp['message'] == 'Forbidden')
        assert (resp['payload'] == {
            'channels': [channel],
        })

        def _cb2(resp, ch=None):
            assert (resp == {
                'message': 'Success',
                'payload': {
                    'channels': {
                        channel: {
                            'r': 1,
                            'm': 0,
                            'w': 1,
                        },
                    },
                    'subscribe_key': subkey,
                    'level': 'channel',
                    'ttl': 10,
                },
            })

            def _cb3(resp, ch=None):
                assert (resp[0] == 1)

                def _cb4(resp, ch=None):
                    assert (resp == {
                        'message': 'Success',
                        'payload': {
                            'channels': {
                                channel: {
                                    'r': 0,
                                    'm': 0,
                                    'w': 0,
                                },
                            },
                            'subscribe_key': subkey,
                            'level': 'channel',
                            'ttl': 1,
                        },
                    })

                    def _cb5(resp, ch=None):
                        print(resp)
                        assert False

                    def _err5(resp):
                        assert (resp['message'] == 'Forbidden')
                        assert (resp['payload'] == {
                            'channels': [channel],
                        })
                    time.sleep(5)
                    pubnub.publish(channel=channel, message=message, callback=_cb5, error=_err5)

                def _err4(resp):
                    assert False
                pubnub_pam.revoke(channel=channel, callback=_cb4, error=_err4)

            def _err3(resp):
                assert False
            time.sleep(5)
            pubnub.publish(channel=channel, message=message, callback=_cb3, error=_err3)

        def _err2(resp):
            assert False
        pubnub_pam.grant(channel=channel, read=True, write=True, ttl=10, callback=_cb2, error=_err2)
    pubnub.publish(channel=channel, message=message, callback=_cb1, error=_err1)

dataset/ETHPy150Open pubnub/python/python-twisted/tests/test_grant_async.py test_10/original