Example #1
0
def test_emails_on_home_page(app, db):
    if len(db.get_addnew_list()) == 0:
        app.addnew.create_new(
            CONTACT(name="Anna",
                    middlename="Ivanovna",
                    lastname="Petrova",
                    nickname="AnPet",
                    title="ZAO",
                    company="Romashka",
                    address="Moscow",
                    home="84951234567",
                    mobile="89161234567",
                    work="88001234567",
                    fax="88000000000",
                    email="*****@*****.**",
                    email2="*****@*****.**",
                    email3="*****@*****.**",
                    address2="Lenina street",
                    phone2="83",
                    notes="16"))

        addnews_ui = sorted(app.addnew.get_addnew_list(),
                            key=CONTACT.id_or_max)
        addnews_db = sorted(db.get_addnew_list(), key=CONTACT.id_or_max)
        assert len(addnews_ui) == len(addnews_db)
        for i in range(len(addnews_ui)):
            assert addnews_ui[i].name == addnews_db[i].name
            assert addnews_ui[i].lastname == addnews_db[i].lastname
            assert addnews_ui[i].address == addnews_db[i].address
            assert clear(addnews_ui[i].all_emails_from_home_page
                         ) == merge_emails_like_on_home_page(addnews_db[i])
            assert clear(addnews_ui[i].all_phones_from_home_page
                         ) == merge_phones_like_on_home_page(addnews_db[i])
Example #2
0
 def get_add_new_info_from_edit_page(self, index):
     wd = self.app.wd
     self.open_add_new_to_edit_by_index(index)
     name = wd.find_element_by_name("firstname").get_attribute("value")
     lastname = wd.find_element_by_name("lastname").get_attribute("value")
     id = wd.find_element_by_name("id").get_attribute("value")
     home = wd.find_element_by_name("home").get_attribute("value")
     mobile = wd.find_element_by_name("mobile").get_attribute("value")
     work = wd.find_element_by_name("work").get_attribute("value")
     phone2 = wd.find_element_by_name("phone2").get_attribute("value")
     address = wd.find_element_by_name("address").get_attribute("value")
     email = wd.find_element_by_name("email").get_attribute("value")
     email2 = wd.find_element_by_name("email2").get_attribute("value")
     email3 = wd.find_element_by_name("email3").get_attribute("value")
     return CONTACT(name=name,
                    lastname=lastname,
                    id=id,
                    email=email,
                    email2=email2,
                    email3=email3,
                    address=address,
                    home=home,
                    mobile=mobile,
                    work=work,
                    phone2=phone2)
Example #3
0
 def get_addnew_list(self):
     list = []
     cursor = self.connection.cursor()
     try:
         cursor.execute(
             "select id, firstname, lastname, address, email, email2, email3, home,"
             " mobile, work, phone2 from addressbook where deprecated='0000-00-00 00:00:00'"
         )
         for row in cursor:
             (id, name, lastname, address, email, email2, email3, home,
              mobile, work, phone2) = row
             list.append(
                 CONTACT(id=str(id),
                         name=name,
                         lastname=lastname,
                         address=address,
                         email=email,
                         email2=email2,
                         email3=email3,
                         home=home,
                         mobile=mobile,
                         work=work,
                         phone2=phone2))
     finally:
         cursor.close()
     return list
def test_add_contact_to_group(app, orm):
    if len(orm.get_group_list()) == 0:
        app.group.create(Group(name="NEW"))
    group = random.choice(orm.get_group_list())
    if len(orm.get_add_new_in_group(group)) == 0:
        app.add_new.create(CONTACT(name="New"))
    contact = random.choice(orm.get_add_new_not_in_group(group))
    app.add_new.add_to_group(contact.id, group.id)
    assert contact in orm.get_add_new_in_group(group)
Example #5
0
 def get_add_new_from_view_page(self, index):
     wd = self.app.wd
     self.open_add_new_view_by_index(index)
     text = wd.find_element_by_id("content").text
     home = re.search("H: (.*)", text).group(1)
     mobile = re.search("M: (.*)", text).group(1)
     work = re.search("W: (.*)", text).group(1)
     phone2 = re.search("P: (.*)", text).group(1)
     return CONTACT(home=home, mobile=mobile, work=work, phone2=phone2)
Example #6
0
def test_add_contact_to_group(app, orm):
    if len(orm.get_group_list()) == 0:
        app.group.create(Group(name="MOYA GROUP"))
    group = random.choice(orm.get_group_list())
    if len(orm.get_addnews_not_in_groups(group)) == 0:
        app.addnew.createnew(
            CONTACT(name="LOLA", middlename="MARTINOVA", lastname="IZOTOVA"))
    addnew = random.choice(orm.get_addnews_not_in_groups(group))
    app.addnew.add_to_group(addnew.id, group.id)
    assert addnew in orm.get_addnews_in_groups(group)
Example #7
0
def test_delete_some_contact(app, orm, check_ui):
    if len(orm.get_addnew_list()) == 0:
        app.addnew.createnew(CONTACT(name="Anna", middlename="Ivanovna", lastname="Petrova"))
    old_addnews = orm.get_addnew_list()
    contact = random.choice(old_addnews)
    app.addnew.delete_contact_by_id(contact.id)
    new_addnews = orm.get_addnew_list()
    assert len(old_addnews) - 1 == len(new_addnews)
    old_addnews.remove(contact)
    assert old_addnews == new_addnews
    if check_ui:
        assert sorted(new_addnews, key=CONTACT.id_or_max) == sorted(app.addnew.get_addnew_list(), key=CONTACT.id_or_max)
Example #8
0
 def convert(contact):
     return CONTACT(id=str(contact.id),
                    name=contact.name,
                    lastname=contact.lastname,
                    address=contact.address,
                    email=contact.email,
                    email2=contact.email2,
                    email3=contact.email3,
                    home=contact.home,
                    mobile=contact.mobile,
                    work=contact.work,
                    fax=contact.fax,
                    phone2=contact.phone2)
Example #9
0
def test_delete_some_add_new(app, db, check_ui):
    if len (db.get_add_new_list()) == 0:
        app.add_new.create(CONTACT(name="test"))
    old_contacts = db.get_add_new_list()
    contact = random.choice(old_contacts)
    print(contact.id)
    app.add_new.delete_add_new_by_id(contact.id)
    new_contacts = db.get_add_new_list()
    assert len(old_contacts) - 1 == len(new_contacts)
    app.add_new.return_to_home_page()
    old_contacts.remove(contact)
    assert old_contacts == new_contacts
    if check_ui:
        assert sorted(new_contacts, key=CONTACT.id_or_max) == sorted(app.add_new.get_add_new_list(),key=CONTACT.id_or_max)
def test_mod_add_new(app):
    app.open_home_page()
    app.add_new.mod_add_new()
    app.add_new.create(
        CONTACT(name="dedx",
                middlename="djk",
                lastname="swsw",
                nickname="nickname",
                title="dededed",
                company="dededed",
                address="dededede",
                mobile="89032012010",
                work="87451241210",
                fax="87451201454",
                email="*****@*****.**",
                byear="1985",
                address2="dedededededrftrgtg",
                phone2="gtggtgtgtgtg",
                notes="gtgrfrffrfrfrf"))

    app.add_new.return_to_home_page()
Example #11
0
 def get_add_new_list(self):
     if self.contact_cache is None:
         wd = self.app.wd
         self.app.open_home_page()
         self.contact_cache = []
         for row in wd.find_elements_by_name("entry"):
             cells = row.find_elements_by_tag_name("td")
             lastname = cells[1].text
             name = cells[2].text
             address = cells[3].text
             id = cells[0].find_element_by_name("selected[]").get_attribute(
                 "value")
             all_email = cells[4].text
             all_phones = cells[5].text
             self.contact_cache.append(
                 CONTACT(lastname=lastname,
                         name=name,
                         id=id,
                         address=address,
                         all_email_from_home_page=all_email,
                         all_phones_from_home_page=all_phones))
     return list(self.contact_cache)
Example #12
0
 def get_addnew_list(self):
     if self.addnew_cache is None:
         wd = self.app.wd
         wd.find_element_by_link_text("home").click()
         self.addnew_cache = []
         for element in wd.find_elements_by_name("entry"):
             cells = element.find_elements_by_tag_name("td")
             name = cells[2].text
             lastname = cells[1].text
             id = cells[0].find_element_by_name("selected[]").get_attribute(
                 "value")
             all_phones = cells[5].text
             all_emails = cells[4].text
             address = cells[3].text
             self.addnew_cache.append(
                 CONTACT(name=name,
                         lastname=lastname,
                         id=id,
                         address=address,
                         all_phones_from_home_page=all_phones,
                         all_emails_from_home_page=all_emails))
     return list(self.addnew_cache)
def test_mod_contact_name(app, orm, check_ui):
    if len(orm.get_addnew_list()) == 0:
        app.addnew.createnew(CONTACT(name="Alisa"))
    old_addnews = orm.get_addnew_list()
    new_addnew = CONTACT(name="Klavdiya")
    mod_addnew = random.choice(old_addnews)
    new_addnew.id = mod_addnew.id
    if new_addnew.name is None:
        new_addnew.name = mod_addnew.name
    if new_addnew.lastname is None:
        new_addnew.lastname = mod_addnew.lastname
    app.addnew.mod_contact_by_id(mod_addnew.id, new_addnew)
    new_addnews = orm.get_addnew_list()
    old_addnews.remove(mod_addnew)
    old_addnews.append(new_addnew)
    assert sorted(old_addnews,
                  key=CONTACT.id_or_max) == sorted(new_addnews,
                                                   key=CONTACT.id_or_max)
    if check_ui:
        assert sorted(new_addnews, key=CONTACT.id_or_max) == sorted(
            app.addnew.get_addnew_list(), key=CONTACT.id_or_max)
Example #14
0
def test_modifyok_contact(app, db, check_ui):
    if len(db.get_add_new_list()) == 0:
        app.add_new.create(CONTACT(name="test"))
    app.open_home_page()
    old_contacts = db.get_add_new_list()
    mod_contact = random.choice(old_contacts)
    new_contact = CONTACT(name="New contact")
    new_contact.id = mod_contact.id
    if new_contact.name is None:
        new_contact.name = mod_contact.name
    if new_contact.lastname is None:
        new_contact.lastname = mod_contact.lastname
    id = new_contact.id
    app.add_new.modifyok_contact_by_id(id, new_contact)
    new_contacts = db.get_add_new_list()
    old_contacts.remove(mod_contact)
    old_contacts.append(new_contact)
    assert sorted(old_contacts,
                  key=CONTACT.id_or_max) == sorted(new_contacts,
                                                   key=CONTACT.id_or_max)
    if check_ui:
        assert sorted(old_contacts, key=CONTACT.id_or_max) == sorted(
            app.add_new.get_add_new_list(), key=CONTACT.id_or_max)
Example #15
0
# -*- coding: utf-8 -*-
from model.contact import CONTACT


testdata = [
    CONTACT(name="name1", middlename="middlename1", lastname="lastname1", nickname="nickname1",
            address="address1", address2="address21"),
    CONTACT(name="name2", middlename="middlename2", lastname="lastname2", nickname="nickname2",
            address="address2", address2="address22")
]


Example #16
0
 def convert(addnew):
     return CONTACT(id=str(addnew.id), name=addnew.name, lastname=addnew.lastname, address=addnew.address,
                    email=addnew.email, email2=addnew.email2, email3=addnew.email3,
                    home=addnew.home, work=addnew.work,
                    mobile=addnew.mobile, phone2=addnew.phone2)
Example #17
0
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(name="", middlename="", lastname="", nickname="nickname",
                    address="address", address2="address2")] + [
    CONTACT(name=random_string("name", 10), lastname=random_string("lastname", 20),
            middlename=random_string("middlename", 20), nickname=random_string("nickname", 10),
            address=random_string("address", 30), address2=random_string("address2", 25))
    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))
Example #18
0
def phone(maxlen):
    symbols = string.digits
    return "".join(
        [random.choice(symbols) for i in range(random.randrange(maxlen))])


testdata = [
    CONTACT(name="",
            middlename="",
            lastname="",
            nickname="",
            title="",
            company="",
            address="",
            mobile="",
            work="",
            fax="",
            email="",
            byear="",
            address2="",
            phone2="",
            notes="")
] + [
    CONTACT(name=random_string("name", 10),
            middlename=random_string("middlename", 10),
            lastname=random_string("lastname", 10),
            nickname=random_string("nickname", 10),
            title=random_string("title", 15),
            company=random_string("company", 7),
            address=random_string("address", 8),
Example #19
0
from model.contact import CONTACT

testdata = [
    CONTACT(name='name1',
            middlename='middlename1',
            lastname='lastname1',
            nickname='nickname1',
            title='title1',
            company='company1',
            address='address1',
            mobile='mobile1',
            work='work1',
            fax='fax1',
            email='email1',
            byear='byear1',
            address2='address21',
            phone2='phone21',
            notes='notes1'),
    CONTACT(name='name2',
            middlename='middlename2',
            lastname='lastname2',
            nickname='nickname2',
            title='title2',
            company='company2',
            address='address2',
            mobile='mobile2',
            work='work2',
            fax='fax2',
            email='email2',
            byear='byear2',
            address2='address22',