def test_should_use_mongo_uri(self): options.mongo_uri = 'mycrazy://uri' Connection.load_config() with mock.patch('motor.MotorClient') as MockMotorClient: MockMotorClient.return_value.open_sync.return_value = 'my' assert Connection.create_client() == 'my' MockMotorClient.assert_called_with(host='mycrazy://uri')
def test_should_compose_uri_with_environ(self): options.mongo_uri = 'mycrazy://{GLB_FEED_MONGO_USR}:{GLB_FEED_MONGO_PWD}@localhost' os.environ['GLB_FEED_MONGO_USR'] = '******' os.environ['GLB_FEED_MONGO_PWD'] = 'fakepass' Connection.load_config() assert Connection._config[ 'mongo_uri'] == 'mycrazy://*****:*****@localhost'
def _reset_config(self): options.db = 'test' options.mongo_uri = 'mongodb://localhost' Connection.load_config()
def test_should_compose_uri_with_environ(self): options.mongo_uri = 'mycrazy://{GLB_FEED_MONGO_USR}:{GLB_FEED_MONGO_PWD}@localhost' os.environ['GLB_FEED_MONGO_USR'] = '******' os.environ['GLB_FEED_MONGO_PWD'] = 'fakepass' Connection.load_config() assert Connection._config['mongo_uri'] == 'mycrazy://*****:*****@localhost'