Exemplo n.º 1
0
 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')
Exemplo n.º 2
0
 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'
Exemplo n.º 3
0
 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')
Exemplo n.º 4
0
 def _reset_config(self):
     options.db = 'test'
     options.mongo_uri = 'mongodb://localhost'
     Connection.load_config()
Exemplo n.º 5
0
 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'
Exemplo n.º 6
0
 def _reset_config(self):
     options.db = 'test'
     options.mongo_uri = 'mongodb://localhost'
     Connection.load_config()