Beispiel #1
0
 def get_test_selection(self):
     return [
         Group(name=name, header=header, footer=footer)
         for name in ["", random_string("name", self.name_max_len)]
         for header in ["", random_string("header", self.data_max_len)]
         for footer in ["", random_string("footer", self.data_max_len)]
     ]
Beispiel #2
0
 def get_groups_count(self, count):
     return [
         Group(name=random_string("name", self.name_max_len),
               header=random_string("header", self.data_max_len),
               footer=random_string("footer", self.data_max_len))
         for _ in range(count)
     ]
Beispiel #3
0
 def get_contacts_count(self, count):
     return [
         Contact(
             firstname=random_string("", self.name_max_len),
             lastname=random_string("", self.name_max_len),
             company=random_string("", self.data_max_len),
             home_tel=random_phone("", self.tel_max_len),
             mobile_tel=random_phone("", self.tel_max_len),
             work_tel=random_phone("", self.tel_max_len),
             sec_tel=random_phone("", self.tel_max_len),
             email=random_email("", self.email_max_len),
             email2=random_email("", self.email_max_len),
             email3=random_email("", self.email_max_len),
             note=random_string("", self.data_max_len),
             address=random_string("", self.data_max_len),
             homepage=random_string("", self.data_max_len),
         ) for _ in range(count)
     ]
Beispiel #4
0
 def get_test_selection(self):
     return [
         Contact(
             firstname=firstname,
             lastname=lastname,
             company=random_string("", self.data_max_len),
             home_tel=random_phone("", self.tel_max_len),
             mobile_tel=random_phone("", self.tel_max_len),
             work_tel=random_phone("", self.tel_max_len),
             sec_tel=random_phone("", self.tel_max_len),
             email=random_email("", self.email_max_len),
             email2=random_email("", self.email_max_len),
             email3=random_email("", self.email_max_len),
             note=random_string("", self.data_max_len),
             address=address,
             homepage=random_string("", self.data_max_len),
         ) for firstname in ["", random_string("", self.name_max_len)]
         for lastname in ["", random_string("", self.name_max_len)]
         for address in ["", random_string("", self.data_max_len)]
     ]
Beispiel #5
0
def test_random_string():
    st = random_string(16)
    print "Random string: {}".format(st)
    assert len(st) == 16
Beispiel #6
0
def test_random_string():
    st = random_string(16)
    print "Random string: {}".format(st)
    assert len(st) == 16
Beispiel #7
0
from model.contact import Contact
from model.utils import random_string, get_random_word
from random import getrandbits, randint, choice
import data.constants as constant

n = randint(1, 10)

testdata = [
    Contact(
        lastname="" if private and bool(getrandbits(1)) else random_string(
            "lastname", 15),
        firstname="" if private and bool(getrandbits(1)) else random_string(
            "firstname", 10),
        middlename="" if private and bool(getrandbits(1)) else random_string(
            "middlename", 15),
        nickname="" if private and bool(getrandbits(1)) else random_string(
            "nickname", 10),
        title="" if private and bool(getrandbits(1)) else random_string(
            "title", 20),
        company="" if private and bool(getrandbits(1)) else random_string(
            "company", 30),
        address="" if private and bool(getrandbits(1)) else random_string(
            "address", 50),
        phone_home="" if phones and bool(getrandbits(1)) else random_string(
            "phone_home", 15),
        mobile="" if phones and bool(getrandbits(1)) else random_string(
            "mobile", 15),
        phone_work="" if phones and bool(getrandbits(1)) else random_string(
            "phone_work", 15),
        fax="" if phones and bool(getrandbits(1)) else random_string(
            "fax", 15),
Beispiel #8
0
 def random():
     return Project(name=random_string(), description=random_string())
Beispiel #9
0
try:
    opts, args = getopt.getopt(sys.argv[1:], "n:f:",
                               ["number of groups", "datafile"])
except:
    getopt.usage()
    sys.exit(2)

n = 5
f = "data/groups.json"

for name, value in opts:
    if name == "-n":
        n = int(value)
    elif name == "-f":
        f = value

testdata = [
    Group(name="" if name else random_string("name", 10),
          header="" if header else random_string("header", 20),
          footer="" if footer else random_string("footer", 20))
    for name in [True, False] for header in [True, False]
    for footer in [True, False]
] + [Group().set_random_parameters_to_random_value() for i in range(n)]

datafile_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..",
                             f)

with open(datafile_path, "w") as datafile:
    jsonpickle.set_encoder_options("json", indent=2)
    datafile.write(jsonpickle.encode(testdata))