コード例 #1
0
ファイル: test_connection.py プロジェクト: Lipvun/torsche
 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')
コード例 #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'
コード例 #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')
コード例 #4
0
ファイル: test_connection.py プロジェクト: Lipvun/torsche
 def _reset_config(self):
     options.db = 'test'
     options.mongo_uri = 'mongodb://localhost'
     Connection.load_config()
コード例 #5
0
ファイル: test_connection.py プロジェクト: Lipvun/torsche
 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'
コード例 #6
0
 def _reset_config(self):
     options.db = 'test'
     options.mongo_uri = 'mongodb://localhost'
     Connection.load_config()