def setUpClass(cls): """Fire up a sandboxed mongodb instance.""" # Enable text search if testing on 2.4 mongobox.mongobox.DEFAULT_ARGS.extend( ['--setParameter', 'textSearchEnabled=true']) cls.box = mongobox.MongoBox() cls.box.start()
def run(args=None): fix_mongo_42() print('\nStarting mongo servers') args = args or [] path, path_auth = _get_mongo_paths() default_params = dict(prealloc=True, mongod_bin=MONGOD_BIN) params = dict(db_path=path, port=MONGO_PORT, **default_params) mongoboxNoAuth = mongobox.MongoBox(**params) params.update(auth=True, db_path=path_auth, port=MONGO_PORT_AUTH) mongoboxAuth = mongobox.MongoBox(**params) status = False statusAuth = False try: # start server print(' - server...', end=' '), sys.stdout.flush() mongoboxNoAuth.start() status = True print('OK') # start auth server print(' - server auth...', end=' '), sys.stdout.flush() mongoboxAuth.start() print('OK') statusAuth = True print(' - admin user on server auth...', end=' '), sys.stdout.flush() update_admin() print('OK\n'), sys.stdout.flush() # run pytest exit(pytest.main(*args)) except Exception: exit(10) finally: # stop servers if status: print('\n\nStoping mongo servers:') print(' - server...', end=' '), sys.stdout.flush() mongoboxNoAuth.stop() print('OK') if statusAuth: print(' - server auth...', end=' '), sys.stdout.flush() mongoboxAuth.stop() print('OK\n'), sys.stdout.flush()
def __enter__(self): if self._use_productionn: print('\n\n###### USING PRODUCTION SERVERS ####\n\n') self.meta = ('https', 'meta.9.0.api.production.infinit.io', 443) else: elle.log.trace('starting mongobox') if self._mongo_port is None: self._mongo = mongobox.MongoBox(dump_file=self.__mongo_dump) self._mongo.__enter__() self._mongo_port = self._mongo.port elle.log.trace('starting meta') self._meta = MetaWrapperProcess(self.__force_admin, self._mongo_port, self.__force_meta_port) self._meta.start() self.trophonius_start() if self.__with_apertus: elle.log.trace('starting apertus') self._apertus = infinit.oracles.apertus.server.Apertus( 'http', '127.0.0.1', self._meta.port, '127.0.0.1', 0, 0, timedelta(seconds=10), timedelta(minutes=5)) elle.log.trace('ready') self.apertus = ('tcp', '127.0.0.1', self._apertus.port_tcp(), self._apertus.port_ssl()) self.meta = ('http', '127.0.0.1', self._meta.port) if self.__setup_client: # Some part of the systems use device_id as an uid (trophonius) # So force each State to use its own. os.environ['INFINIT_FORCE_NEW_DEVICE_ID'] = '1' os.environ['INFINIT_NO_DIR_CACHE'] = '1' # Python will honor environment variables TMPDIR,TEMP,TMP if os.environ.get('TEST_INFINIT_HOME', False): elle.log.log('Forcing home from environment') os.environ['INFINIT_HOME'] = os.environ['TEST_INFINIT_HOME'] else: self.__cleanup_dirs.append(tempfile.mkdtemp('infinit-test')) os.environ['INFINIT_HOME'] = self.__cleanup_dirs[-1] self.home_dir = os.environ['INFINIT_HOME'] if os.environ.get('TEST_INFINIT_DOWNLOAD_DIR', False): elle.log.log('Forcing download dir from environment') os.environ['INFINIT_DOWNLOAD_DIR'] = os.environ[ 'TEST_INFINIT_DOWNLOAD_DIR'] else: self.__cleanup_dirs.append(tempfile.mkdtemp('infinit-test-dl')) os.environ['INFINIT_DOWNLOAD_DIR'] = self.__cleanup_dirs[-1] self.download_dir = os.environ['INFINIT_DOWNLOAD_DIR'] return self
def setUp(self): self.box = mongobox.MongoBox(scripting=True, auth=True) self.box.start() self.boxclient = self.box.client() self.boxclient['admin'].add_user('foo','bar') self.boxclient['admin'].authenticate('foo','bar') self.boxclient['test'].add_user('test','test') base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) config = utils.load_config(os.path.join(base_dir, 'test/adsdata.cfg.test')) config['ADSDATA_MONGO_DATABASE'] = 'test' config['ADSDATA_MONGO_HOST'] = 'localhost' config['ADSDATA_MONGO_PORT'] = self.box.port config['ADSDATA_MONGO_USER'] = '******' config['ADSDATA_MONGO_PASSWORD'] = '******' self.config = config self.session = utils.get_session(config) load_data(self.config)
def __init__(self, enable_emails=False, enable_invitations=False, force_admin=False, emailer=None, metrics=None, smser=None, **kw): self.__mongo = mongobox.MongoBox() self.__server = bottle.WSGIRefServer(port=0) self.__database = None self.__client = None self.__enable_emails = enable_emails self.__enable_invitations = enable_invitations self.__force_admin = force_admin self.__meta = None self.__meta_args = kw self.__metrics = metrics if 'shorten_ghost_profile_url' not in self.__meta_args: self.__meta_args['shorten_ghost_profile_url'] = False self.__emailer = emailer or TestEmailer() self.__smser = smser or TestSMSer() self.__version = infinit.oracles.meta.server.Meta.extract_version( Version.version, '')
def setUpClass(cls): """Fire up a sandboxed mongodb instance.""" cls.box = mongobox.MongoBox() cls.box.start()