Пример #1
0
 def test_distinct_insert2(self):
     conn = Couch("test")
     test_doc = {"adsf": {"bbb": "fdsa", "aand": "ssss"}}
     for i in range(3):
         conn.distinct_insert(test_doc)
     query_result = conn.query(test_doc)
     conn.close()
     self.assertEqual(1, len(query_result))
Пример #2
0
 def test_delete(self):
     obj = {"abc": "1234", "def": "4567"}
     selector = {"abc": "1234"}
     db = Couch('test')
     db.distinct_insert(obj)
     query_result = db.query(selector)
     self.assertTrue(len(query_result) > 0)
     db.delete(selector)
     query_result = db.query(selector)
     self.assertEqual(0, len(query_result))
Пример #3
0
 def test_move_doc(self):
     obj = {"i": "tomove"}
     db = Couch('test')
     doc_id = db.distinct_insert(obj)
     selector = {'_id': doc_id}
     Couch('test').move_doc(selector, 'test2')
     query_result = Couch('test2').query(obj)
     self.assertTrue(len(query_result) > 0)
Пример #4
0
 def test_update(self):
     obj = {"abc": "1234", "def": {"abc": "4567"}}
     db = Couch('test')
     doc_id = db.distinct_insert(obj)
     selector = {'_id': doc_id}
     Couch('test').update(selector, 'def', {"abc": "5678"})
     res = Couch('test').query(selector)
     for item in res:
         self.assertEqual(item['def'], {"abc": "5678"})
Пример #5
0
 def store_result(info1, info2, vector, database):
     database = Couch(database)
     doc = {
         'platform1': info1['platform'],
         'platform2': info2['platform'],
         'username1': info1['profile']['username'],
         'username2': info2['profile']['username'],
         'vector': vector
     }
     logger.info('Storing result: {}'.format(doc))
     doc_id = database.distinct_insert(_convert_float(doc))
     database.close()
     return doc_id