Пример #1
0
 def _create_source(filter=None, bucket_auto=None):
   kwargs = {}
   if filter is not None:
     kwargs['filter'] = filter
   if bucket_auto is not None:
     kwargs['bucket_auto'] = bucket_auto
   return _BoundedMongoSource('mongodb://test', 'testdb', 'testcoll', **kwargs)
Пример #2
0
  def setUp(self, mock_client):
    self._ids = [
        objectid.ObjectId.from_datetime(
            datetime.datetime(year=2020, month=i + 1, day=i + 1))
        for i in range(5)
    ]
    self._docs = [{'_id': self._ids[i], 'x': i} for i in range(len(self._ids))]
    mock_client.return_value = _MockMongoClient(self._docs)

    self.mongo_source = _BoundedMongoSource('mongodb://test', 'testdb',
                                            'testcoll')
 def test_display_data_mask_password(self):
     # Uri without password
     data = self.mongo_source.display_data()
     self.assertTrue('uri' in data)
     self.assertTrue(data['uri'] == 'mongodb://test')
     # Password is masked in the uri if present
     mongo_source = _BoundedMongoSource(
         'mongodb+srv://user:[email protected]/testdb',
         'testdb',
         'testcoll',
         extra_client_params={
             'user': '******',
             'password': '******'
         })
     data = mongo_source.display_data()
     self.assertTrue('uri' in data)
     self.assertTrue(
         data['uri'] == 'mongodb+srv://user:******@test.mongodb.net/testdb')
     # Password is masked in the client spec if present
     self.assertTrue('mongo_client_spec' in data)
     self.assertTrue(data['mongo_client_spec'] ==
                     '{"user": "******", "password": "******"}')
Пример #4
0
 def setUp(self, mock_size, mock_count):
     mock_size.return_value = 10
     mock_count.return_value = 5
     self.mongo_source = _BoundedMongoSource('mongodb://test', 'testdb',
                                             'testcoll')