def clean(contact):
     return Contact(id=contact.id,
                    firstname=" ".join(
                        contact.firstname.strip().split()),
                    lastname=" ".join(contact.lastname.strip().split()))
Esempio n. 2
0
from model.contact import Contact

testdata = [
    Contact(firstname='firstname1',
            middlename='middlename1',
            lastname='lastname1',
            nickname='nickname1',
            title='title1',
            company='company1',
            address='address1',
            home='home1',
            mobile='mobile1',
            work='work1',
            fax='fax1',
            email='email1',
            email2='email21',
            email3='email31',
            homepage='homepage1',
            bday='bday1',
            bmonth='bmonth1',
            byear='byear1',
            aday='aday1',
            amonth='amonth1',
            ayear='ayear1',
            address2='address21',
            phone2='phone21',
            notes='notes1'),
    Contact(firstname='firstname2',
            middlename='middlename2',
            lastname='lastname2',
            nickname='nickname2',
Esempio n. 3
0
    # generate string of random length and random symbols
    return prefix + "".join(
        [random.choice(symbols) for i in range(random.randrange(maxlen))])


def random_phone(prefix, maxlen):
    symbols = string.digits + re.sub("['`\"]", "", string.punctuation)
    # generate string of random length and random symbols
    return prefix + "".join(
        [random.choice(symbols) for i in range(random.randrange(maxlen))])


testdata = [
    Contact(first_name="",
            middle_name="",
            last_name="",
            nick_name="",
            email="",
            address="")
] + [
    Contact(first_name=random_string("f_name", 10),
            last_name=random_string("l_name", 10),
            nick_name=random_string("n_name", 10),
            middle_name=random_string("m_name", 10),
            address=random_string("address", 30),
            email=random_email("email", 20),
            email2=random_email("email2", 20),
            email3=random_email("email3", 20),
            home_phone=random_phone('812', 10),
            mobile_phone=random_phone('911', 15),
            work_phone=random_phone("000", 10),
            fax_phone=random_phone("777", 10)) for i in range(n)
from model.contact import Contact
import random
import string

def random_string(prefix, maxlen):
    symbols = string.ascii_letters + string.digits + string.punctuation + " "*10
    return prefix+"".join([random.choice(symbols) for i in range(random.randrange(maxlen))])

def random_digits(maxlen):
    return "".join([random.choice(string.digits) for i in range(random.randrange(maxlen))])


testdata = [Contact(first_name=first_name, middle_name=middle_name, last_name=last_name,
                    home_telephone=home_telephone, mobile_telephone=mobile_telephone,
                    work_telephone=work_telephone, email1=email1
                    # title=title, company=company, company_address=company_address,
                    #   home_telephone=home_telephone, mobile_telephone=mobile_telephone, work_telephone=work_telephone,
                    #   fax=fax, email1=email1, email2=email2, email3=email3, homepage=homepage, address=address,
                    #   secondary_telephone=secondary_telephone, notes=notes
                    )
            for first_name in ["", random_string("first_name", 10)]
            for middle_name in ["", random_string("middle_name", 10)]
            for last_name in ["", random_string("last_name", 10)]
            for home_telephone in ["", random_digits(10)]
            for mobile_telephone in ["", random_digits(10)]
            for work_telephone in ["", random_digits(10)]
            # for fax in ["", random_digits(10)]
            for email1 in ["", random_string("title", 10)]
            # for email2 in ["", random_string("title", 10)]
            # for email3 in ["", random_string("title", 10)]
            # for homepage in ["", random_string("homepage", 10)]
            # for address in ["", random_string("address", 20)]
Esempio n. 5
0
 def convert(contact):
     return Contact(id=str(contact.id),
                    firstname=contact.firstname,
                    lastname=contact.lastname)
def test_delete_first_contact(app):
    if app.contact.count() == 0:
        app.contact.new_contact(Contact(firstname="Brad", middlename="BP", lastname="Pitt", nickname="Braddy", photo="C:\\12.jpg", title="Junior", company="21 Fox", address="Hollywood", homenumber="123456789",
                         mobile="987654321", worknumber="678901234", fax="123123123", website="www.pitt.com", email="*****@*****.**", byear="1989", ayear="1900",
                         address2="Miami", phone2="785269555", notes="Notes here"))
    app.contact.delete_first_contact()
Esempio n. 7
0
def non_empty_contact_list(db, gen):
    if len(db.get_contact_list()) == 0:
        gen.contact.create(Contact(first_name="modify"))
    return db.get_contact_list()
Esempio n. 8
0
except getopt.GetoptError as err:
    getopt.usage()
    sys.exit(2)

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

for o, a in opts:
    if o == "-n":
        n = int(a)
    elif o == "-f":
        f = a


def random_string(prefix, maxlen):
    symbols = string.ascii_letters + string.digits + string.punctuation + " " * 10
    return prefix + "".join(
        [random.choice(symbols) for i in range(random.randrange(maxlen))])


testdata = [Contact(firstname="", lastname="")] + [
    Contact(firstname=random_string("fname", 10),
            lastname=random_string("lname", 10)) for i in range(5)
]

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

with open(file, "w") as out:
    jsonpickle.set_encoder_options("json", indent=2)
    out.write(jsonpickle.encode(testdata))
def test_add_new_contact(app, db, check_ui):
    if app.contact.count() == 0:
        app.contact.create_new_contact(
            Contact(first_name="first_name",
                    middle_name="middle_name",
                    last_name="last_name",
                    nickname="nickname",
                    company="some_company",
                    address_1="123 Tice Blvd.",
                    mobile_phone="2013912500",
                    address_2="Woodcliff Lake",
                    home_phone="2013912501",
                    work_phone="2013912502",
                    fax="2013912503",
                    email_2="*****@*****.**",
                    email_3="*****@*****.**",
                    email_1="*****@*****.**",
                    website="http://homepage.com",
                    group_phone="8885016953",
                    birth_day="17",
                    birth_month="February",
                    anniversary_date="18",
                    anniversary_month="December",
                    anniversary_year="1990",
                    birth_year="1990"))

    contact = Contact(first_name="EDITED FIRST NAME",
                      middle_name="",
                      last_name="EDITED LAST NAME",
                      nickname="",
                      company="",
                      address_1="ADDRESS_1",
                      mobile_phone="",
                      address_2="",
                      home_phone="",
                      work_phone="",
                      fax="",
                      email_2="",
                      email_3="",
                      email_1="",
                      website="",
                      group_phone="",
                      birth_day="",
                      birth_month="",
                      anniversary_date="",
                      anniversary_month="",
                      anniversary_year="",
                      birth_year="")
    contact.id = app.contact.get_contacts_list()[0].id
    old_contacts = db.get_contact_list()
    app.contact.edit_first_contact(contact)
    new_contacts = db.get_contact_list()
    for i in range(len(old_contacts)):
        if old_contacts[i].id == contact.id:
            old_contacts[i] = contact
    assert sorted(old_contacts,
                  key=Contact.id_or_max) == sorted(new_contacts,
                                                   key=Contact.id_or_max)
    if check_ui:
        assert sorted(new_contacts, key=Contact.id_or_max) == sorted(
            app.group.get_contact_list(), key=Contact.id_or_max)
def test_add_empty_contact(app):
    app.session.login(User.ADMIN)
    empty_contact = Contact().set_empty_parameters()  # generate empty contact
    app.contact.create(empty_contact)
    app.session.logout()
def test_add_random_contact(app):
    app.session.login(User.ADMIN)
    random_contact = Contact().set_all_parameters_to_random_value(
    )  # generate fully random contact
    app.contact.create(random_contact)
    app.session.logout()
Esempio n. 12
0
    return str(random.randrange(1, 32))


def random_month():
    return random.choice([
        "January", "February", "March", "April", "May", "June", "July",
        "August", "September", "October", "November", "December"
    ])


def random_year():
    return str(random.randrange(1900, 2022))


test_data = [
    Contact(firstname="", lastname="", address="", email="", mobile_phone="")
] + [
    Contact(firstname=random_string("firstname", 10),
            lastname=random_string("lastname", 10),
            address=random_string("address", 30),
            email=random_email(),
            mobile_phone=random_phone(15),
            bday=random_day(),
            bmonth=random_month(),
            byear=random_year()) for i in range(n)
]

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

with open(file, "w") as out:
    jsonpickle.set_encoder_options("json", indent=2)
Esempio n. 13
0
def random_number(maxlen):
    symbols = string.digits
    return "".join(
        [random.choice(symbols) for i in range(random.randrange(maxlen))])


testdata = [
    Contact(firstname="",
            middlename="",
            lastname="",
            nickname="",
            title="",
            company="",
            address="",
            homephone="",
            mobilephone="",
            workphone="",
            fax="",
            email="",
            email2="",
            email3="",
            homepage="",
            address2="",
            phone2="",
            notes="")
] + [
    Contact(firstname=random_string("firstname", 5),
            middlename=random_string("middlename", 5),
            lastname=random_string("lastname", 5),
            nickname=random_string("nickname", 5),
            title=random_string("title", 5),
            company=random_string("company", 5),
Esempio n. 14
0
def random_string_letters(prefix, maxlen):
    symbols = string.ascii_letters
    return prefix + ''.join(
        [random.choice(symbols) for i in range(random.randrange(maxlen))])


def random_string_digits(maxlen):
    symbols = string.digits
    return ''.join(
        [random.choice(symbols) for i in range(random.randrange(maxlen))])


testdata = [
    Contact(firstname=random_string_letters('firstname', 10),
            lastname=random_string_letters('lastname', 10),
            title=random_string_letters('title', 10),
            address=random_string_letters('address', 10),
            email=random_string_letters('email', 10),
            mobilephone=random_string_digits(10),
            homephone=random_string_digits(10),
            workphone=random_string_digits(10),
            secondaryphone=random_string_digits(10)) for i in range(n)
]

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

with open(file, 'w') as out:
    jsonpickle.set_encoder_options('json', indent=2)
    out.write(jsonpickle.encode(testdata))
Esempio n. 15
0
def test_add_contact(app):
    app.contact.create(
        Contact(fname="somename", mname="somemname", lname="somelname"))
Esempio n. 16
0
    elif o =="-f":
        f = a

def random_string_for_names(prefix, maxlen):
    symbols = string.ascii_letters + " "
    return prefix + "".join([random.choice(symbols) for i in range(random.randrange(maxlen))])

def random_string_for_phones(maxlen):
    symbols = string.digits*3 + " +()" + "-"*3
    return "".join([random.choice(symbols) for i in range(random.randrange(maxlen))])

def random_string_for_address(maxlen):
    symbols = string.ascii_letters + string.digits + " ,."*5
    return "".join([random.choice(symbols) for i in range(random.randrange(maxlen))])

def random_string_for_email(maxlen):
    symbols = string.ascii_letters*3 + string.digits + "-_#&+"
    return "".join([random.choice(symbols) for i in range(random.randrange(maxlen))])

testdata = [Contact(firstname=random_string_for_names("name", 15), lastname=random_string_for_names("surname", 20),
            nickname=random_string_for_address(20), company=random_string_for_names("company", 30),
            address=random_string_for_address(60), homephone=random_string_for_phones(14),
            workphone=random_string_for_phones(14), mobilephone=random_string_for_phones(14),
            secondaryphone=random_string_for_phones(14),email=random_string_for_email(30) + "@" + random.choice(["mail.ru", "gmail.com",
            "yandex.ru", "i.ua", "ukr.net"])) for i in range(n)]

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

with open(file, "w") as out:
    jsonpickle.set_encoder_options("json", indent=2)
    out.write(jsonpickle.encode(testdata))
Esempio n. 17
0
n = 5
f = "data/contacts.json"

for o, a in opts:
    if o == "-n":
        n = int(a)
    elif o == "-f":
        f = a

testdata = [
    Contact(firstname="",
            middlename="",
            lastname="",
            nickname="",
            address="",
            homephone="",
            mobilephone="",
            workphone="",
            secondaryphone="",
            email="",
            email2="",
            email3="")
] + [
    Contact(firstname=random_string("", 10, "letters"),
            middlename=random_string("", 20, "letters"),
            lastname=random_string("", 20, "letters"),
            nickname=random_string("", 10, "letters"),
            address=random_string("", 20, "allstring"),
            homephone=random_string("", 20, "digits"),
            mobilephone=random_string("", 10, "digits"),
            workphone=random_string("", 10, "digits"),
            secondaryphone=random_string("", 20, "digits"),
Esempio n. 18
0
from model.contact import Contact

testdata = [Contact(first_name="first_name1", surname="surname1")]
Esempio n. 19
0
def new_contact(first_name, last_name, address, home_phone):
    return Contact(first_name=first_name,
                   last_name=last_name,
                   address=address,
                   home_phone=home_phone)
Esempio n. 20
0
from model.contact import Contact

test_data = Contact(firstname='test_fn', lastname='test_ln',
                    homephone='test_hp', mobilephone='test_mp', workphone='test_wp')
Esempio n. 21
0
def modify_data(first_name, last_name, address, home_phone):
    return Contact(first_name=first_name,
                   last_name=last_name,
                   address=address,
                   home_phone=home_phone)
Esempio n. 22
0
    return prefix + "".join(
        [random.choice(symbols) for i in range(random.randrange(3, maxlen))])


testdata = [
    Contact(firstname=random_string("firstname_", 10),
            middlename=random_string("middlename_", 10),
            lastname=random_string("lastname_", 10),
            nickname=random_string("nickname_", 8),
            photo="C:\\fakepath\\Untitled.jpg",
            title=random_string("title_", 6),
            company=random_string("company_", 10),
            address=random_string("address_", 8),
            home=random_string("home_", 6),
            mobile=random_string("mobile_", 10),
            work=random_string("work_", 8),
            fax=random_string("fax_", 6),
            email=random_string("email_", 10),
            email2=random_string("email2_", 8),
            email3=random_string("email3_", 6),
            homepage=random_string("homepage_", 10),
            birthday="11 May 1977",
            anniversary="3 June 1959",
            address2=random_string("address2_", 8),
            phone2=random_string("phone2_", 6),
            notes=random_string("notes_", 20)) for i in range(n)
]

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

with open(file, "w") as out:
Esempio n. 23
0
         for i in range(random.randrange(maxlen))]) + "@gmail.com"


testdata = [
    Contact(_first_name="",
            _middle_name="",
            _last_name="",
            _nickname="",
            _tittle="",
            _company="",
            _address="",
            _telephone_home="",
            _telephone_mobile="",
            _telephone_work="",
            _fax="",
            _email="",
            _email_2="",
            _email_3="",
            _homepage="",
            _bday="",
            _bmonth="-",
            _byear="",
            _aday="",
            _amonth="-",
            _ayear="",
            _secondary_address="",
            _secondary_home="",
            _secondary_notes="")
] + [
    Contact(_first_name=random_string("firstname", 15),
            _middle_name=random_string("middlename", 15),
            _last_name=random_string("lastname", 15),
Esempio n. 24
0
def test_add_contact(app):
    app.contact.create(Contact(first_name="Alexey", last_name="Platonov", nickname="Lanossar", mobile="0984250484", email="*****@*****.**"))
Esempio n. 25
0
def random_email(prefix, name_maxlen):
    symbols = string.ascii_letters + string.digits + " " * 10
    return prefix + "".join([random.choice(symbols) for i in range(random.randrange(name_maxlen))]) + "@" \
           + random.choice(["mail", "com", "gmail", "".join([random.choice(symbols) for i in range(random.randrange(10))])]) + "."\
           + random.choice(["ru", "by", "com"])


testdata = [
    Contact(firstname="Ivan",
            middlename="Ivanovich",
            lastname="Ivanov",
            nickname="Iva",
            title="zaq",
            company="comp1",
            address="st. Qwerty 1",
            phones=Phones(homephone="8(017)2851111",
                          mobilephone="+375297111111",
                          workphone="8(017)2841111",
                          secondaryphone="285-33-77",
                          faxphone="8(017)2841111"),
            emails=Emails(email1="*****@*****.**",
                          email2="*****@*****.**",
                          email3="*****@*****.**"))
] + [
    Contact(firstname=random_name("first", 10),
            middlename=random_name("middle", 20),
            lastname=random_name("last", 20),
            address=random_address(4, 10),
            emails=Emails(email1=random_email("em1", 4),
                          email2=random_email("em2", 7),
                          email3=random_email("em3", 5))) for i in range(n)
Esempio n. 26
0
bday_list = list(map(lambda x: str(x), range(1, 31)))
bmonth_list = [
    "January", "February", "March", "April", "May", "June", "July", "August",
    "September", "October", "November", "December"
]
byear_list = list(map(lambda x: str(x), range(1900, 2019)))

testdata = [
    Contact(firstname="",
            lastname="",
            nickname="",
            company="",
            homephone="",
            mobilephone="",
            workphone="",
            fax="",
            secondaryphone="",
            email="",
            email2="",
            email3="",
            address="",
            bday=random.choice(bday_list),
            bmonth=random.choice(bmonth_list),
            byear=random.choice(byear_list))
] + [
    Contact(firstname=random_string("firstname", 10),
            lastname=random_string("lastname", 20),
            nickname=random_string("nickname", 10),
            company=random_string("company", 10),
            homephone=random_string("homephone", 10),
            mobilephone=random_string("mobilephone", 10),
            workphone=random_string("workphone", 10),
Esempio n. 27
0
from model.contact import Contact

testdata = [
    Contact(first_name="name1", last_name="lastname1", birthday="12-April-1985",
            address="street1", mobile_phone="321554", email="*****@*****.**",
            company="companyname1"),
    Contact(first_name="name2", last_name="lastname2", birthday="29-September-1999",
            address="street2", mobile_phone="9840005", email="*****@*****.**",
            company="companyname2")
]
Esempio n. 28
0
def test_edit_info(app, db, check_ui):
    old_contact = db.get_contact_list()
    if len(db.get_contact_list()) == 0:
        app.contact.open_add_new()
        app.contact.fill_form(
            Contact(firstname="",
                    middlename="",
                    lastname="",
                    nickname="",
                    title="",
                    company="",
                    address="",
                    telhome="",
                    telmob="",
                    telwork="",
                    fax="",
                    email="",
                    mail2="",
                    mail3="",
                    homepage="",
                    years1="",
                    years2="",
                    address2="",
                    phone2="",
                    nots="",
                    bday="-",
                    aday="-",
                    bmonth="-",
                    amonth="-",
                    photo=None))
        app.contact.save_created()
    app.contact.open_home_page()

    contact = Contact(firstname="restname",
                      middlename="restmidl",
                      lastname="restlas",
                      nickname="rettnicl",
                      title="resttit",
                      company="restcomp",
                      address="restadd - asd;m / asd/ 12",
                      telhome="+7(666)151-424-77",
                      telmob="+7(666)151-44-44",
                      telwork="444",
                      fax="44444",
                      email="*****@*****.**",
                      mail2="*****@*****.**",
                      mail3="*****@*****.**",
                      homepage="*****@*****.**",
                      years1="1990",
                      years2="1998",
                      address2="rerererer",
                      phone2="REEER",
                      nots="REREf",
                      bday="10",
                      aday="10",
                      bmonth="April",
                      amonth="July",
                      photo=None)
    contact1 = random.choice(old_contact)
    app.contact.select_contact_by_id_for_edit(contact1.id)
    app.contact.fill_form(contact)
    app.contact.save_edit_info()
    new_contact = db.get_contact_list()
    assert len(old_contact) == len(new_contact)
    old_contact.remove(contact1)
    old = app.contact.merge(old_contact, new_contact)
    assert sorted(old, key=Contact.id_or_max) == sorted(new_contact,
                                                        key=Contact.id_or_max)
    if check_ui:
        assert sorted(new_contact, key=Contact.id_or_max) == sorted(
            app.contact.get_contact_list(), key=Contact.id_or_max)
def test_delete_any_contact_from_itself(app):
    if app.contact.count() == 0:
        contact = Contact(lastname='first', firstname='contact')
        app.contact.create(contact)
    app.contact.delete_any_contact_from_itself()
Esempio n. 30
0
def test_delete_contact(app):
    if app.contact.count() == 0:
        app.contact.create(Contact(name="test"))
    app.contact.delete_first_contact()