def install(): IDC.objects.create(name='ALL', comment='ALL') IDC.objects.create(name='默认', comment='默认') DEPT.objects.create(name="默认", comment="默认部门") DEPT.objects.create(name="超管部", comment="超级管理员部门") dept = DEPT.objects.get(name='超管部') dept2 = DEPT.objects.get(name='默认') UserGroup.objects.create(name='ALL', dept=dept, comment='ALL') UserGroup.objects.create(name='默认', dept=dept, comment='默认') BisGroup.objects.create(name='ALL', dept=dept, comment='ALL') BisGroup.objects.create(name='默认', dept=dept, comment='默认') User(id=5000, username="******", password=md5_crypt('admin'), name='admin', email='*****@*****.**', role='SU', is_active=True, dept=dept).save() User(id=5001, username="******", password=md5_crypt('group_admin'), name='group_admin', email='*****@*****.**', role='DA', is_active=True, dept=dept2).save()
def test_add_user(): for i in range(1, 500): username = "******" + str(i) dept_all = DEPT.objects.all() group_all = UserGroup.objects.all() group_all_id = [group.id for group in group_all] db_add_user(username=username, password=md5_crypt(username), dept=random.choice(dept_all), name=username, email='*****@*****.**' % username, groups=[random.choice(group_all_id) for i in range(1, 4)], role='CU', ssh_key_pwd=CRYPTOR.encrypt(username), ldap_pwd=CRYPTOR.encrypt(username), is_active=True, date_joined=datetime.datetime.now()) print "Add: %s" % username