Ejemplo n.º 1
0
def populate_user_db(user_database, ids):
    email_shift = 0
    ids['address'] = {}
    ids['department'] = {}
    ids['user'] = {}
    ids['useraddress'] = []
    for adress in adresses:
        ids['address'][adress] = AddressService.add(user_database, adress)
    for department in departments:
        ids['department'][department] = DepartmentService.add(user_database, department)
        for username in chinese_names:
            mail = "w_" + str(email_shift) + "@mail.tsinghua.edu.cn"
            ids['user'][username] = UserService.add(user_database, email_shift, username.decode('utf8'), mail, ids['department'][department]) 
            email_shift = email_shift + 1
            for _ in range(random.randint(1, 3)):
                addr_num = random.randint(0, len(adresses) - 1)
                ids['useraddress'].append(UserAddressService.add(user_database, ids['address'][adresses[addr_num]], ids['user'][username]))
Ejemplo n.º 2
0
from src.com.mailsystem.services.MailStateHistoryService import MailStateHistoryService
from src.com.mailsystem.services.StateService import StateService
from src.com.mailsystem.services.UserAddressService import UserAddressService
from src.com.mailsystem.services.UserService import UserService
import src.com.mailsystem.codes as codes

db_users = Database('mailsystem_users')
db_d1 = Database('mailsystem_d1')
databases = { 'users': db_users,
              'D1': db_d1 }

codes.codes = { "01": "D1" }
codes.rev_codes = { "D1": "01" }


a1 = AddressService.add(db_users, "A1")
a2 = AddressService.add(db_users, "A2")
d1 = DepartmentService.add(db_users, "D1")
s1 = StateService.add(db_users, "S1")
s2 = StateService.add(db_users, "S2")
s3 = StateService.add(db_users, "S3")
u1 = UserService.add(db_users, 2013400576, "U1", "[email protected]", d1)
ua1 = UserAddressService.add(db_users, a1, u1)
ua2 = UserAddressService.add(db_users, a2, u1)
bc = MailService.add(databases, s1, ua1, ua2)

las = UserAddressService.listByUser(db_users, u1)

selectedMail = MailService.selectByBarcode(databases['D1'], bc)

print las