def setUp(self): AsyncTestCase.setUp(self) return_value = { 'label': 'A Label', 'comment': 'A Comment', 'depiction': 'A URL' } future = Future() future.set_result(return_value) self._wrapped_fn = Mock(return_value=future) self._decorated_fn = cache_facts(self._wrapped_fn) #setup a function with a value to be cached #and decorate it with the decorated under test @cache_facts def intense_fact_processing(uri): return { 'label': 'A Label', 'comment': 'A Comment', 'depiction': 'A URL', 'uri': uri } self.intense_fact_processing = intense_fact_processing
def setUp(self): AsyncTestCase.setUp(self) TornadoAsyncTestCase.setUp(self) self.http_server = Server(enable_ssl=self.get_protocol() == 'https') self.http_server.start() self.http_server.started_event.wait(timeout=5.0) self._port = self.http_server.port
def setUp(self): AsyncTestCase.setUp(self) self.response_callback = SpyMethod() self.server = PServer(self.response_callback, NetStringConn, io_loop = self.io_loop) self.server.handle_stream = SpyMethod() self.port = get_unused_port() self.server.listen(self.port)
def setUp(self): AsyncTestCase.setUp(self) pnconf = PNConfiguration() pnconf.publish_key = 'demo' pnconf.subscribe_key = 'demo' pnconf.enable_subscribe = False self.pn = PubNubTornado(pnconf, custom_ioloop=self.io_loop)
def setUp(self): AsyncTestCase.setUp(self) config = Configuration() config.host = HOST self.api_client = petstore_api.ApiClient(config) self.pet_api = petstore_api.PetApi(self.api_client) self.setUpModels() self.setUpFiles()
def setUp(self): AsyncTestCase.setUp(self) for key in options.keys(): del options[key] define_common_options() define_node_options() parse_config_file(os.path.join(DIR, 'config_data.py')) self.init_storages() self.node_oid = str(uuid.uuid1()) Cluster.instance().init()
def tearDown(self): self.server.stop() # does not work with current pymongo for db_name in self.mongo_client.database_names(): self.mongo_client.drop_database(db_name) # end fix shutil.rmtree(self.state_dir) AsyncTestCase.tearDown(self) MongoTestCase.tearDown(self)
def setUp(self): SynTest.setUp(self) AsyncTestCase.setUp(self) core = synapse.cortex.openurl('ram://') self.wapp = s_webapp.WebApp() self.wapp.listen(0, host='127.0.0.1') self.host = 'http://127.0.0.1:%d' % (self.wapp.getServBinds()[0][1]) for model_name in ['foo', 'bar']: self.wapp.addHandPath('/v1/(%s)' % (model_name), s_webapp.CrudHand, core=core) self.wapp.addHandPath('/v1/(%s)/([^/]+)' % (model_name), s_webapp.CrudHand, core=core)
def setUp(self): AsyncTestCase.setUp(self) self.http_client = MockHTTPClient(force_instance=True) self.handler = tornado_logging_slack.TornadoSlackHandler( 'my-key', 'my-channel', 'my-username', http_client=self.http_client ) self.logger = logging.Logger('test') self.logger.addHandler(self.handler)
def setUp(self): AsyncTestCase.setUp(self) port = get_unused_port() sock = netutil.bind_sockets(port, 'localhost', family=socket.AF_INET)[0] setattr(self, '_AsyncHTTPTestCase__port', port) self.__port = port self.http_client = self.get_http_client() self._app = self.get_app() self.http_server = self.get_http_server() self.http_server.add_sockets([sock])
def setUp(self): AsyncTestCase.setUp(self) dbname = 'test_db' + str(randint(100, 100000)) self.handler = CushionHandler() self.handler.prepare() # typically, this would be called in the Handler.prepare() self.handler.db_setup( dbname, baseurl, io_loop=self.io_loop, callback=self.stop, create=True ) self.wait() # create one test record self.handler.cushion.save(self.handler.db_default, {'fake':'data'}, callback=self.stop) rec = self.wait() self.record = rec.raw()
def setUp(self): AsyncTestCase.setUp(self) self.response_callback = echo_handler self.server = PServer(self.response_callback, NetStringConn, io_loop = self.io_loop) #self.server = proxy_spy(self.server) self.port = get_unused_port() self.server.listen(self.port) conn_info = socket.getaddrinfo('127.0.0.1', self.port, socket.AF_UNSPEC, socket.SOCK_STREAM) af, socktype, proto, conname, saddress = conn_info[0] # print(conn_info) # print(socket.AF_INET, socket.SOCK_STREAM) self.server_address = saddress self.sock = socket.socket(af, socktype, 6) # In the examples from net, the protocol version is 0 self.stream = iostream.IOStream(self.sock, self.io_loop) # client must have the same event loop, otherwise it will create new one self.server.start()
def setUp(self): AsyncTestCase.setUp(self) # now create our test cushion object self.cushion = Cushion(baseurl, io_loop=self.io_loop) assert isinstance(self.cushion._server, trombi.Server) # create a test db self.dbname = 'test_db' + str(randint(100, 100000)) # connect to our database # this tests our open(..) method on cushion. I'd rather have it # in a separate test, but we need this database and if open fails here, # everything else should tank, so setUp is as good a place as any. self.cushion.create(self.dbname, self.stop) self.wait() self.cushion.open(self.dbname, self.stop) self.wait() # we're after the db has been added assert isinstance(self.cushion._pool[self.dbname], trombi.Database)
def setUp(self): MongoTestCase.setUp(self) AsyncTestCase.setUp(self) self.state_dir = tempfile.mkdtemp() cfg = os.path.join(self.state_dir, "inmanta.cfg") with open(cfg, "w"): pass config.Config.load_config(cfg) config.Config.get( "database", "name", "inmanta-" + ''.join(random.choice(string.ascii_letters) for _ in range(10))) config.Config.set("config", "state-dir", self.state_dir) config.Config.set("config", "log-dir", os.path.join(self.state_dir, "logs")) config.Config.set("server_rest_transport", "port", PORT) config.Config.set("agent_rest_transport", "port", PORT) config.Config.set("compiler_rest_transport", "port", PORT) config.Config.set("client_rest_transport", "port", PORT) config.Config.set("cmdline_rest_transport", "port", PORT) config.Config.set( "config", "executable", os.path.abspath(os.path.join(__file__, "../../src/inmanta/app.py"))) config.Config.set("server", "agent-timeout", "2") LOGGER.info("Starting server") mongo_port = os.getenv('MONGOBOX_PORT') if mongo_port is None: raise Exception( "MONGOBOX_PORT env variable not available. Make sure test are executed with --with-mongobox" ) self.server = Server(database_host="localhost", database_port=int(mongo_port), io_loop=self.io_loop)
def tearDown(self): self.btc.close(callback=self.stop) self.wait(timeout=0.1) AsyncTestCase.tearDown(self)
def setUp(self): AsyncTestCase.setUp(self) config = pnconf_mc_copy() config.enable_subscribe = False self.pn = PubNubTornado(config, custom_ioloop=self.io_loop)
def tearDown(self): AsyncTestCase.tearDown(self) self.summarum_endpoint = None
def __init__(self, methodName='runTest'): # noqa: H803 MongoTestCase.__init__(self, methodName) AsyncTestCase.__init__(self, methodName) self.state_dir = None self.server = None
def setUp(self): AsyncTestCase.setUp(self)
def setUp(self): AsyncTestCase.setUp(self) self.summarum_endpoint = Endpoint()
def tearDown(self): AsyncTestCase.tearDown(self)
def setUp(self): AsyncTestCase.setUp(self) self.handler = AYHandler() self.handler.prepare()
def setUp(self): AsyncTestCase.setUp(self) self.dbpedia_endpoint = DBpediaEndpoint() response = [ { "o": { "xml: lang": "en", "type": "literal", "value": "Sample Label" }, "p": { "type": "uri", "value": "http://www.w3.org/2000/01/rdf-schema#label" }, "predicate_label": { "type": "literal", "value": "label" } }, { "o": { "type": "uri", "value": "http://upload.wikimedia.org/wikipedia/commons/sample_depiction.jpg" }, "p": { "type": "uri", "value": "http://xmlns.com/foaf/0.1/depiction" }, "predicate_label": { "type": "literal", "value": "depiction" } }, { "o": { "type": "uri", "value": "http://upload.wikimedia.org/wikipedia/commons/sample_thumbnail.jpg" }, "p": { "type": "uri", "value": "http://dbpedia.org/ontology/thumbnail" }, "predicate_label": { "type": "literal", "value": "thumbnail" } }, { "o": { "xml: lang": "en", "type": "literal", "value": "Sample Abstract" }, "p": { "type": "uri", "value": "http://dbpedia.org/ontology/abstract" }, "predicate_label": { "xml: lang": "en", "type": "literal", "value": "has abstract" } }, { "o": { "xml: lang": "en", "type": "literal", "value": "Sample Comment" }, "p": { "type": "uri", "value": "http://www.w3.org/2000/01/rdf-schema#comment" }, "predicate_label": { "xml: lang": "en", "type": "literal", "value": "comment" } }, { "o": { "type": "uri", "value": "http://en.wikipedia.org/wiki/Sample" }, "p": { "type": "uri", "value": "http://xmlns.com/foaf/0.1/isPrimaryTopicOf" }, "predicate_label": { "type": "literal", "value": "is primary topic of" } } ] future = Future() future.set_result(response) self.dbpedia_endpoint.fetch = Mock(return_value=future) self.fact_service = FactService(endpoint = self.dbpedia_endpoint)
def tearDown(self): self.http_server.stop() self.http_server.join(timeout=5) AsyncTestCase.tearDown(self) TornadoAsyncTestCase.tearDown(self)
def setUp(self): AsyncTestCase.setUp(self) self.url = projects_url self.data = project_data self.project_id = project_id
def setUp(self): AsyncTestCase.setUp(self) self.uri = 'http://dbpedia.com/resource/Sample' self.endpoint = Mock() self.ranking_service = RankingService(self.uri, endpoint=self.endpoint)
def setUp(self): AsyncTestCase.setUp(self) self.tmp_email = "*****@*****.**" self.tmp_password = "******" self.tmp_roles = ["admin"] self._create_user()
def setUp(self): AsyncTestCase.setUp(self) self.dbpedia_endpoint = DBpediaEndpoint()
def setUp(self): AsyncTestCase.setUp(self) self.dbpedia_endpoint = DBpediaEndpoint() response = [{ "o": { "xml: lang": "en", "type": "literal", "value": "Sample Label" }, "p": { "type": "uri", "value": "http://www.w3.org/2000/01/rdf-schema#label" }, "predicate_label": { "type": "literal", "value": "label" } }, { "o": { "type": "uri", "value": "http://upload.wikimedia.org/wikipedia/commons/sample_depiction.jpg" }, "p": { "type": "uri", "value": "http://xmlns.com/foaf/0.1/depiction" }, "predicate_label": { "type": "literal", "value": "depiction" } }, { "o": { "type": "uri", "value": "http://upload.wikimedia.org/wikipedia/commons/sample_thumbnail.jpg" }, "p": { "type": "uri", "value": "http://dbpedia.org/ontology/thumbnail" }, "predicate_label": { "type": "literal", "value": "thumbnail" } }, { "o": { "xml: lang": "en", "type": "literal", "value": "Sample Abstract" }, "p": { "type": "uri", "value": "http://dbpedia.org/ontology/abstract" }, "predicate_label": { "xml: lang": "en", "type": "literal", "value": "has abstract" } }, { "o": { "xml: lang": "en", "type": "literal", "value": "Sample Comment" }, "p": { "type": "uri", "value": "http://www.w3.org/2000/01/rdf-schema#comment" }, "predicate_label": { "xml: lang": "en", "type": "literal", "value": "comment" } }, { "o": { "type": "uri", "value": "http://en.wikipedia.org/wiki/Sample" }, "p": { "type": "uri", "value": "http://xmlns.com/foaf/0.1/isPrimaryTopicOf" }, "predicate_label": { "type": "literal", "value": "is primary topic of" } }] future = Future() future.set_result(response) self.dbpedia_endpoint.fetch = Mock(return_value=future) self.fact_service = FactService(endpoint=self.dbpedia_endpoint)
def setUp(self): AsyncTestCase.setUp(self) self.btc = beanstalkt.Client(io_loop=self.io_loop) self.btc.connect(callback=self.stop) self.wait(timeout=0.1)
def tearDown(self): self.wapp.fini() AsyncTestCase.tearDown(self) SynTest.tearDown(self)
def setUp(self): AsyncTestCase.setUp(self) config = pnconf_copy() self.pn = PubNubTornado(config, custom_ioloop=self.io_loop)
def setUp(self): AsyncTestCase.setUp(self) self.env = None
def setUp(self): AsyncTestCase.setUp(self) self.config_dir = os.path.join('/tmp/', str(uuid.uuid4())) os.mkdir(self.config_dir) options['config_dir'].set(self.config_dir)