Beispiel #1
0
    def test_id_no_changes(self):
        self.file_cache.id("test_file_name", "test_file_name", 8)

        self.assertFalse(self.mock_metadata.called)
        mock_calls = [call.find_one({'name': 'test_file_name', 'parent': 8})]
        self.assertEqual(self.mongo_db.mock_calls, mock_calls)
        self.assertFalse(self.mongo_db.save.called)
    def test_id_no_changes(self):
        self.file_cache.id("test_file_name", "test_file_name", 8)

        self.assertFalse(self.mock_metadata.called)
        mock_calls = [call.find_one({'name': 'test_file_name', 'parent': 8})]
        self.assertEqual(self.mongo_db.mock_calls,mock_calls)
        self.assertFalse(self.mongo_db.save.called)
Beispiel #3
0
 def test_find_one(self):
     from pymongo.objectid import ObjectId
     doc = MagicMock()
     self.db.db.docs.find_one.return_value = doc
     result = self.db.find_one('1' * 24)
     assert call.find_one({'_id': ObjectId('111111111111111111111111'
                          )}) == self.db.db.docs.mock_calls[0]
     assert doc == result.doc
Beispiel #4
0
 def test_find_one(self):
     from pymongo.objectid import ObjectId
     doc = MagicMock()
     self.db.db.docs.find_one.return_value = doc
     result = self.db.find_one('1' * 24)
     assert call.find_one({'_id': ObjectId('111111111111111111111111')
                           }) == self.db.db.docs.mock_calls[0]
     assert doc == result.doc