Esempio n. 1
0
 def set_dumper(self, **kwargs):
     if 'dumper' in kwargs:
         self.dumper = kwargs['dumper']
     else:
         self.dumper = Mongodump.Mongodump(host=self.host,
                                           db=self.db,
                                           collections=[self.col])
Esempio n. 2
0
 def test_cmd_multiple_collections(self):
     mongodump = Mongodump.Mongodump(host='127.0.0.1',
                                     db='teste',
                                     collections=['log0', 'log1'])
     prefix = ['mongodump', '--host', '127.0.0.1', '--db', 'teste']
     par1 = {'host': '127.0.0.1', 'db': 'teste', 'collection': 'log0'}
     par2 = {'host': '127.0.0.1', 'db': 'teste', 'collection': 'log1'}
     self.assertEqual(mongodump.runpars, [par1, par2])
Esempio n. 3
0
 def test_run_dump_directory(self):
     mongodump = Mongodump.Mongodump(host='127.0.0.1',
                                     db='teste',
                                     collections=['log'],
                                     caller=successful_call)
     mongodump.run()
     directories = [
         name for name in os.listdir(os.getcwd()) if os.path.isdir(name)
     ]
     self.assertTrue('dump' in directories)
Esempio n. 4
0
 def test_setquery(self):
     mongodump = Mongodump.Mongodump(host='127.0.0.1',
                                     db='teste',
                                     collections=['log'])
     mongodump.set_query({"timestamp": {"$gt": 10000}})
     pars = [{
         'host': '127.0.0.1',
         'db': 'teste',
         'collection': 'log',
         'query': '{"timestamp": {"$gt": 10000}}'
     }]
     self.assertEqual(mongodump.query, '{"timestamp": {"$gt": 10000}}')
     self.assertEqual(mongodump.runpars, pars)
Esempio n. 5
0
 def test_behavior_with_invalid_hosts(self):
     mongodump = Mongodump.Mongodump(host='servidor_invalido',
                                     caller=erroneoushost_call)
     with self.assertRaises(CalledProcessError):
         mongodump.run()
Esempio n. 6
0
 def test_run_objectnumber(self):
     mongodump = Mongodump.Mongodump(host='127.0.0.1',
                                     db='teste',
                                     collections=['log'],
                                     caller=successful_call)
     self.assertEqual(mongodump.get_objectsdumped(), [603980])
Esempio n. 7
0
 def test_cmd_no_collection(self):
     mongodump = Mongodump.Mongodump(host='127.0.0.1', db='teste')
     pars = {'host': '127.0.0.1', 'db': 'teste'}
     self.assertEqual(mongodump.runpars, [pars])