How to use the tornado.testing.gen_test function in tornado

To help you get started, we’ve selected a few tornado examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jucacrispim / mongomotor / tests / functional / test_tornado.py View on Github external
        @gen_test
        def test_modify_unknown_object(self):
            yield self.maindoc.objects.modify(id=ObjectId(), docname='dn')
            total = yield self.maindoc.objects.all().count()

            self.assertEqual(total, 0)
            self.assertFalse(None)
github CenterForOpenScience / waterbutler / tests / server / test_utils.py View on Github external
    @testing.gen_test
    def test_set_default_headers_options(self):
        origin = 'http://foo.com'

        self.handler.request = MockRequest(
            method='OPTIONS',
            headers={
                'Origin': origin,
            }
        )
        self.handler.set_default_headers()
        assert origin == self.handler.headers['Access-Control-Allow-Origin']
github erkyrath / tworld / lib / twest / test_funcs.py View on Github external
    @tornado.testing.gen_test
    def test_global_funcs(self):
        yield self.resetTables()
        
        task = two.task.Task(self.app, None, 1, 2, twcommon.misc.now())
        ctx = EvalPropContext(task, loctx=self.loctx, level=LEVEL_EXECUTE)

        res = yield ctx.eval('len("xyzzy")', evaltype=EVALTYPE_CODE)
        self.assertEqual(res, 5)
        res = yield ctx.eval('len(ls)', evaltype=EVALTYPE_CODE)
        self.assertEqual(res, 3)
        res = yield ctx.eval('min(5,3,4)', evaltype=EVALTYPE_CODE)
        self.assertEqual(res, 3)
        res = yield ctx.eval('min([5,3,4])', evaltype=EVALTYPE_CODE)
        self.assertEqual(res, 3)
        res = yield ctx.eval('max(5,3,4)', evaltype=EVALTYPE_CODE)
        self.assertEqual(res, 5)
github pubnub / python / tests / integrational / tornado / test_channel_groups.py View on Github external
    @tornado.testing.gen_test
    def test_add_remove_multiple_channels(self):
        ch1 = "channel-groups-tornado-ch1"
        ch2 = "channel-groups-tornado-ch2"
        gr = "channel-groups-tornado-cg"

        # add
        env = yield self.pubnub.add_channel_to_channel_group() \
            .channels([ch1, ch2]).channel_group(gr).future()

        assert isinstance(env.result, PNChannelGroupsAddChannelResult)

        yield gen.sleep(1)

        # list
        env = yield self.pubnub.list_channels_in_channel_group().channel_group(gr).future()
        assert isinstance(env.result, PNChannelGroupsListResult)
github holmes-app / holmes-api / tests / unit / handlers / test_domains_violations_prefs.py View on Github external
    @gen_test
    def test_can_save_prefs_as_superuser(self):
        self.db.query(User).delete()
        user = UserFactory(email='superuser@user.com', is_superuser=True)
        domain = DomainFactory.create(name='globo.com')
        key = KeyFactory.create(name='some.random')
        DomainsViolationsPrefsFactory.create(domain=domain, key=key, value=100)

        loaded_prefs = DomainsViolationsPrefs.get_domains_violations_prefs_by_domain(self.db, domain.name)
        expect(loaded_prefs).to_length(1)
        expect(loaded_prefs[0]).to_be_like({
            'value': 100,
            'key': 'some.random'
        })

        yield self.authenticated_fetch(
            '/domains/%s/violations-prefs/' % domain.name,
github gmr / tredis / tests.py View on Github external
    @testing.gen_test
    def test_exists_single(self):
        yield self.client.connect()
        key = str(uuid.uuid4()).encode('ascii')
        value = str(uuid.uuid4()).encode('ascii')
        result = yield self.client.set(key, value)
        self.assertTrue(result)
        result = yield self.client.exists(key)
        self.assertTrue(result)
github CenterForOpenScience / waterbutler / tests / server / api / v0 / test_move.py View on Github external
    @testing.gen_test
    def test_conflict(self):
        self.source_provider.move = utils.MockCoroutine(
            return_value=(utils.MockFileMetadata(), True)
        )

        payload = self.payload()
        payload['conflict'] = 'keep'

        resp = yield self.http_client.fetch(
            self.get_url('/ops/move'),
            method='POST',
            body=json.dumps(payload)
        )

        assert resp.code == 201
        assert self.source_provider.move.called
github awslabs / aws-iot-analytics-notebook-containers / tst / iota_notebook_containers / test_export_to_ecr.py View on Github external
    @tornado.testing.gen_test
    def test_GIVEN_protocol_acting_as_ifclose_message_recieved_WHEN_upload_to_repo_THEN_lock_cleared(self):
        on_message_backup = UploadToRepoHandler.on_message
        def on_message(handler, message):
            handler.write_message("")
        try:
            UploadToRepoHandler.on_message = on_message
            self.assertFalse(IsContainerizationOngoingHandler.is_containerization_ongoing())
            request_url = "ws://localhost:" + str(self.get_http_port()) + "/upload_to_repo"
            ws1 = yield tornado.websocket.websocket_connect(request_url)
            ws1.write_message(json.dumps(False))
            _ = yield ws1.read_message()
            self.assertTrue(IsContainerizationOngoingHandler.is_containerization_ongoing())
            old_containerizing_client = UploadToRepoHandler.containerizing_client
            self.assertNotEqual(None, old_containerizing_client)
            # this is what the protocol object does when it recieves a close message request
            # i do this rather than send a close message request directly because it would be hard to
github coldnight / gredis / tests / test_gredis.py View on Github external
    @gen_test
    def test_blocking_pipeline(self):
        key = "g_pipeline_test"
        key1 = "g_pipeline_test1"
        pipeline = self.client.pipeline()

        pipeline.set(key, "gredis")
        pipeline.set(key1, "gredis1")
        pipeline.execute()

        ret = yield self.client.get(key)
        self.assertEqual(ret, "gredis")
        ret1 = yield self.client.get(key1)
        self.assertEqual(ret1, "gredis1")
github Thriftpy / thrift_connector / tests / test_tornado.py View on Github external
    @tornado.testing.gen_test
    def test_roundrobin_multiconnection_pool(self):
        servers = [
            (self.pingpong_thrift_client.host,
             self.pingpong_thrift_client.port),
            (self.pingpong_thrift_client.host,
             self.pingpong_thrift_client.port2),
        ]

        from thrift_connector.tornado import TornadoRoundRobinMultiServerClient
        roundrobin_pool = TornadoRoundRobinMultiServerClient(
            self.pingpong_thrift_client.pool.service,
            servers=servers,
            name=self.pingpong_thrift_client.pool.name,
            raise_empty=False, max_conn=3,
            connection_class=self.pingpong_thrift_client.pool.connection_class,
        )