예제 #1
0
 def test_save(self):
     database = mock()
     document = Document('Elena X')
     when(database).save(document).thenReturn(True)
     client = Client(database)
     result = client.save(document)
     self.assertTrue(result)
예제 #2
0
파일: convert.py 프로젝트: alfredormz/lai
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import codecs
from lai import Client, Database, Document

client = Client(Database())
filename = '/home/xleo/src/tools12/trunk/scripts/lai/data'

with codecs.open(filename, 'r', encoding='latin1') as file:
    lines = file.readlines()
    count = 0
    for line in lines[1772:]:
        if line != '':
            doc = Document(line.strip())
            doc.set_keys(line)
            doc = client.save(doc)
            if count % 25 == 0:
                client.commit()
            count += 1