コード例 #1
0
 def test_update_new(self):
     data = self._gen_data()
     index = EssentialIndex('f2')
     index.create_index(data)
     data['new'] = {'f1': 'v1a', 'f2': 'newval', 'f3': 10, "_id": "new"}
     index.update_index(data['new'])
     items = index.find(data, 'newval')
     self.assertEqual(len(items), 1)
コード例 #2
0
 def test_update_existing(self):
     data = self._gen_data()
     index = EssentialIndex('f2')
     index.create_index(data)
     data['b'] = {'f1': 'v1a', 'f2': 'updatedval', 'f3': 10, "_id": "b"}
     index.update_index(data['b'])
     items = index.find(data, 'updatedval')
     self.assertEqual(len(items), 1)
コード例 #3
0
 def test_remove_existing(self):
     data = self._gen_data()
     index = EssentialIndex('f2')
     index.create_index(data)
     items = index.find(data, 'v2')
     self.assertEqual(len(items), 3)
     removed = index.remove_from_index(data['b'])
     self.assertTrue(removed)
     items = index.find(data, 'v2')
     self.assertEqual(len(items), 2)
コード例 #4
0
 def test_remove_non_existing(self):
     data = self._gen_data()
     index = EssentialIndex('f2')
     index.create_index(data)
     removed = index.remove_from_index({'_id': 'doesnt exist'})
     self.assertFalse(removed)
     removed = index.remove_from_index({'no id': 'doesnt exist'})
     self.assertFalse(removed)
コード例 #5
0
 def createIndex(self, index_document, options=None):
     for key in index_document:
         if index_document[key] == "hashed":
             index = EssentialIndex(key)
             index.create_index(self.documents)
             self.indexes[key] = index
コード例 #6
0
 def test_find_unique(self):
     data = self._gen_data()
     index = EssentialIndex('f1')
     index.create_index(data)
     items = index.find(data, 'v1a')
     self.assertEqual(len(items), 1)
コード例 #7
0
 def test_find_none(self):
     data = self._gen_data()
     index = EssentialIndex('f2')
     index.create_index(data)
     items = index.find(data, 'v444')
     self.assertEqual(len(items), 0)
コード例 #8
0
 def test_create_index_unique(self):
     data = self._gen_data()
     index = EssentialIndex('f1')
     index_dict = index.create_index(data)
     self.assertEqual(len(index_dict), 3)
コード例 #9
0
 def test_create_index_multiple(self):
     data = self._gen_data()
     index = EssentialIndex('f2')
     index_dict = index.create_index(data)
     self.assertEqual(len(index_dict), 1)
コード例 #10
0
 def test_find_none(self):
     index = EssentialIndex()
     index.create_index(data, 'f2')
     items = index.find(data, 'v444')
     self.assertEqual(len(items), 0)
コード例 #11
0
 def test_find_multiple(self):
     index = EssentialIndex()
     index.create_index(data, 'f2')
     items = index.find(data, 'v2')
     self.assertEqual(len(items), 3)
コード例 #12
0
 def test_find_unique(self):
     index = EssentialIndex()
     index.create_index(data, 'f1')
     items = index.find(data, 'v1a')
     self.assertEqual(len(items), 1)
コード例 #13
0
 def test_create_index_multiple(self):
     index = EssentialIndex()
     index_dict = index.create_index(data, 'f2')
     self.assertEqual(len(index_dict), 1)
コード例 #14
0
 def test_create_index_unique(self):
     index = EssentialIndex()
     index_dict = index.create_index(data, 'f1')
     self.assertEqual(len(index_dict), 3)