Example #1
0
 def test021_drop(self):
     d = Database(db_path, mode=mode, serializer=serializer)
     c = d.test021
     c.drop()
     self.assertFalse('test021' in d.collection_names(),
                      msg='Nin operand failed')
     d.create_collection('test021')
     d.drop_collection('test021')
     self.assertFalse('test021' in d.collection_names(),
                      msg='Nin operand failed')
Example #2
0
    def test001_newdb(self):
        print('=> %s::%s' % (mode, serializer))
        d = Database(db_path, mode=mode, serializer=serializer)
        d.drop_collection('test')
        d.drop_collection('test2')
        self.assertNotIn('test',
                         d.collection_names(),
                         msg='Database not empty (drop failure)')
        self.assertNotIn('test2',
                         d.collection_names(),
                         msg='Database not empty (drop failure)')
        d.sync()

        _db = _serializer.load()
        self.assertNotIn('test', _db)
        self.assertNotIn('test2', _db)
        self.assertFalse(_db['_infos']['total_entries'] > 0,
                         msg='Ids index is not empty')
Example #3
0
 def test002_new_collection(self):
     d = Database(db_path, mode=mode, serializer=serializer)
     d.test.save({'key': 'value'})
     self.assertIn('test',
                   d.collection_names(),
                   msg='Collection not created')
     d.sync()
     _db = _serializer.load()
     self.assertFalse(_db['_infos']['total_entries'] > 1,
                      msg='Ids index is not empty')
Example #4
0
    c = db[collection]
    for i in range(nb_entrie_per_collection):
        c.save(entrie)


def worker(db):
    for i in range(nb_collection):
        db.create_collection(str(uuid.uuid4()))

    for i in db.collection_names():
        populate_collection(db, i, entrie)


if __name__ == "__main__":
    print(' :: Collections            : %s' % nb_collection)
    print(' :: Entrie per collection  : %s' % nb_entrie_per_collection)
    #print(' :: Entrie style         :\n %s' % entrie)
    db = Database(path=db_path, mode=mode, serializer=serializer)
    start_time = time.time()
    worker(db)

    total_time = time.time() - start_time
    print(' :: Total in second        : %s' % total_time)
    print(' :: Second per entrie      : %s' %
          (total_time / (nb_collection * nb_entrie_per_collection)))
    total_entries = 0
    for c in db.collection_names():
        total_entries += db[c].count()
    print(' :: Total database entries : %s' % total_entries)
#   os.remove(db_path)