コード例 #1
0
 def test_explain_type_error(self):
     docs = []
     with patch('pymongo.cursor.Cursor.explain') as explain_mock, \
          patch('mongodrums.instrument.push') as push_mock:
         explain_mock.side_effect = TypeError()
         push_mock.side_effect = docs.append
         with instrument():
             self.db.foo.find({'name': 'zed'})
             self.db.foo.update({'name': 'zed'}, {'$set': {'age': 40}})
     for doc in docs:
         self.assertIn('error', doc['explain'])
コード例 #2
0
 def test_explain_type_error(self):
     docs = []
     with patch('pymongo.cursor.Cursor.explain') as explain_mock, \
          patch('mongodrums.instrument.push') as push_mock:
         explain_mock.side_effect = TypeError()
         push_mock.side_effect = docs.append
         with instrument():
             self.db.foo.find({'name': 'zed'})
             self.db.foo.update({'name': 'zed'}, {'$set': {'age': 40}})
     for doc in docs:
         self.assertIn('error', doc['explain'])
コード例 #3
0
 def test_instrumented(self):
     self.assertFalse(instrumented())
     with instrument():
         self.assertTrue(instrumented())
     self.assertFalse(instrumented())
コード例 #4
0
 def test_config_update(self):
     with instrument():
         self.assertEqual(pymongo.collection.Collection.find._frequency,
                          self.saved_config.instrument.sample_frequency)
         update({'instrument': {'sample_frequency': 1}})
         self.assertEqual(pymongo.collection.Collection.find._frequency, 1)
コード例 #5
0
 def test_instrumented(self):
     self.assertFalse(instrumented())
     with instrument():
         self.assertTrue(instrumented())
     self.assertFalse(instrumented())
コード例 #6
0
 def test_config_update(self):
     with instrument():
         self.assertEqual(pymongo.collection.Collection.find._frequency,
                          self.saved_config.instrument.sample_frequency)
         update({'instrument': {'sample_frequency': 1}})
         self.assertEqual(pymongo.collection.Collection.find._frequency, 1)