summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2010-10-23 01:00:00 +0100
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2010-10-23 01:00:00 +0100
commit5c189c4754968092ce97470737085ed60f9dab94 (patch)
tree5df681fd21516d556038750491e58acbb056d845
parent74d1d469d6c26e449daa03a6d00689d1d2d7b3ae (diff)
downloadpykolab-5c189c4754968092ce97470737085ed60f9dab94.tar.gz
Fix some other errors as well
-rw-r--r--pykolab/tests/create-contacts.py22
-rw-r--r--pykolab/tests/kaddress-contact.tpl6
2 files changed, 19 insertions, 9 deletions
diff --git a/pykolab/tests/create-contacts.py b/pykolab/tests/create-contacts.py
index caff1b0..5423faa 100644
--- a/pykolab/tests/create-contacts.py
+++ b/pykolab/tests/create-contacts.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
# Copyright 2010 Kolab Systems AG (http://www.kolabsys.com)
@@ -23,7 +24,7 @@
import os, random, sys
if __name__ == "__main__":
- num = int(sys.argv[1])
+ wanted_num = int(sys.argv[1])
contact_tpl_file = open('./kaddress-contact.tpl', 'r')
contact_tpl_orig = contact_tpl_file.read()
@@ -35,8 +36,11 @@ if __name__ == "__main__":
alphabet = "abcdefghijklmnopqrstuvwxwz"
+ user_num = 0
+
for user in users:
- for contact in xrange(num):
+ num = 0
+ while num <= wanted_num:
uid = "%s.%s" %(str(random.randint(1000000000,9999999999)),str(random.randint(0,999)).zfill(3))
if not uid in uid_alloc:
uid_alloc.append(uid)
@@ -45,6 +49,8 @@ if __name__ == "__main__":
domain = domains[random.randint(0,2)]
+ contact_tpl = contact_tpl_orig
+
birthday = ""
if random.randint(0,100) >= 75:
year = str(random.randint(1960, 2010))
@@ -54,16 +60,17 @@ if __name__ == "__main__":
middle_names = ""
if random.randint(0,100) >= 50:
- middle_names = random.sample(alphabet, (4, 8)).capitalize()
+ middle_names = ''.join(random.sample(alphabet, random.randint(4, 8))).capitalize()
number = ""
if random.randint(0,100) >= 25:
number = "+441234567890"
- given_name = random.sample(alphabet, (4, 8)).capitalized()
- last_name = random.sample(alphabet, (4, 8)).capitalized()
+ given_name = ''.join(random.sample(alphabet, random.randint(4, 8))).capitalize()
+ last_name = ''.join(random.sample(alphabet, random.randint(4, 8))).capitalize()
contact = {
+ 'uid': uid,
'user': user,
'user_email': "%s@%s" % (user, domain),
'given_name': given_name,
@@ -87,10 +94,13 @@ if __name__ == "__main__":
for key in contact.keys():
contact_tpl = contact_tpl.replace("@@%s@@" % key, '%s' % contact[key])
- out.write(event_tpl)
+ out.write(contact_tpl)
out.close()
+
try:
os.chown("%s/%d." %(directory,num), 19415, 19415)
except:
pass
+ num += 1
+ user_num += 1
diff --git a/pykolab/tests/kaddress-contact.tpl b/pykolab/tests/kaddress-contact.tpl
index 542498a..c685245 100644
--- a/pykolab/tests/kaddress-contact.tpl
+++ b/pykolab/tests/kaddress-contact.tpl
@@ -4,7 +4,7 @@ Date: Thu, 20 May 2010 09:04:51 +0100
MIME-Version: 1.0
X-Kolab-Type: application/x-vnd.kolab.contact
Content-Type: Multipart/Mixed;
- boundary="Boundary-00=_j0O9Lpj9TsAjYEA"
+ boundary="Boundary-00=@@uid@@"
Status: RO
X-Status: OT
X-KMail-EncryptionState:
@@ -37,7 +37,7 @@ Content-Disposition: attachment;
<given-name>@@given_name@@</given_name>
<middle-names>@@middle_names@@</middle-names>
<last-name>@@last_name@@</last-name>
- <full-name>@@full_name@</full-name>
+ <full-name>@@full_name@@</full-name>
</name>
<email>
<display-name>@@display_name@@</display-name>
@@ -51,4 +51,4 @@ Content-Disposition: attachment;
<preferred-address>home</preferred-address>
</contact>
---Boundary-00=@@uid@@-- \ No newline at end of file
+--Boundary-00=@@uid@@--