Exemple #1
0
 def test_exceptions1(self):
     mongo_connection = MongoProxy(
         MongoConnection(exceptions_to_raise=[ValueError]), methods_needing_retry={MongoConnection: ['find', ]}
     )
     with self.assertRaises(ValueError):
         mongo_connection.find()
     self.assertEqual(mongo_connection.call_count, 1)
Exemple #2
0
 def test_exceptions1(self):
     mongo_connection = MongoProxy(
         MongoConnection(exceptions_to_raise=[ValueError]),
         methods_needing_retry={MongoConnection: [
             'find',
         ]})
     with self.assertRaises(ValueError):
         mongo_connection.find()
     self.assertEqual(mongo_connection.call_count, 1)
Exemple #3
0
 def test_exceptions2(self):
     mongo_connection = MongoProxy(
         MongoConnection(exceptions_to_raise=[AutoReconnect, AutoReconnect]),
         methods_needing_retry={MongoConnection: ['find', ]}
     )
     self.assertEqual(mongo_connection.find(), "Finished.")
     self.assertEqual(mongo_connection.call_count, 3)
Exemple #4
0
 def test_no_exceptions1(self):
     mongo_connection = MongoProxy(
         MongoConnection(),
         methods_needing_retry={MongoConnection: [
             'find',
         ]})
     self.assertEqual(mongo_connection.find(), "Finished.")
     self.assertEqual(mongo_connection.call_count, 1)
Exemple #5
0
 def test_exceptions2(self):
     mongo_connection = MongoProxy(
         MongoConnection(
             exceptions_to_raise=[AutoReconnect, AutoReconnect]),
         methods_needing_retry={MongoConnection: [
             'find',
         ]})
     self.assertEqual(mongo_connection.find(), "Finished.")
     self.assertEqual(mongo_connection.call_count, 3)
Exemple #6
0
 def test_no_exceptions1(self):
     mongo_connection = MongoProxy(MongoConnection(), methods_needing_retry={MongoConnection: ['find', ]})
     self.assertEqual(mongo_connection.find(), "Finished.")
     self.assertEqual(mongo_connection.call_count, 1)