Ejemplo n.º 1
0
 def test_commit(self, mock_uuid, mock_dump_pickle, mock_open):
     mock_dump_pickle.return_value = True
     mock_uuid.return_value = 1
     exporter_config = ExporterConfig(self.config)
     persistence = PicklePersistence(exporter_config.persistence_options, meta())
     self.assertEqual(None, persistence.commit_position(10))
     self.assertEqual(persistence.get_metadata('commited_positions'), 1)
Ejemplo n.º 2
0
 def test_get_last_position(self, mock_load_pickle, mock_dump_pickle, mock_open, mock_is_file):
     mock_dump_pickle.return_value = True
     mock_is_file.return_value = True
     mock_load_pickle.return_value = {'last_position': {'last_key': 10}}
     exporter_config = ExporterConfig(self.config)
     persistence = PicklePersistence(exporter_config.persistence_options, meta())
     self.assertEqual({'last_key': 10}, persistence.get_last_position())
Ejemplo n.º 3
0
 def test_commit(self, mock_uuid, mock_dump_pickle, mock_open):
     mock_dump_pickle.return_value = True
     mock_uuid.return_value = 1
     exporter_config = ExporterConfig(self.config)
     persistence = PicklePersistence(exporter_config.persistence_options,
                                     meta())
     self.assertEqual(None, persistence.commit_position(10))
     self.assertEqual(persistence.get_metadata('commited_positions'), 1)
Ejemplo n.º 4
0
 def test_get_last_position(self, mock_load_pickle, mock_dump_pickle,
                            mock_open, mock_is_file):
     mock_dump_pickle.return_value = True
     mock_is_file.return_value = True
     mock_load_pickle.return_value = {'last_position': {'last_key': 10}}
     exporter_config = ExporterConfig(self.config)
     persistence = PicklePersistence(exporter_config.persistence_options,
                                     meta())
     self.assertEqual({'last_key': 10}, persistence.get_last_position())
Ejemplo n.º 5
0
 def test_create_persistence_job(self, mock_uuid, mock_pickle):
     file_name = '1'
     mock_pickle.dump.return_value = True
     mock_uuid.return_value = file_name
     exporter_config = ExporterConfig(self.config)
     try:
         persistence = PicklePersistence(
             exporter_config.persistence_options, meta())
         self.assertIsInstance(persistence, PicklePersistence)
         persistence.close()
     finally:
         remove_if_exists('/tmp/'+file_name)
Ejemplo n.º 6
0
 def test_create_persistence_job(self, mock_uuid, mock_pickle):
     file_name = '1'
     mock_pickle.dump.return_value = True
     mock_uuid.return_value = file_name
     exporter_config = ExporterConfig(self.config)
     try:
         persistence = PicklePersistence(
             exporter_config.persistence_options, meta())
         self.assertIsInstance(persistence, PicklePersistence)
         persistence.close()
     finally:
         remove_if_exists('/tmp/' + file_name)