コード例 #1
0
def test_modify_first_contact_firstname(app):
    old_contactss = app.contacts.get_contactss_list()
    checking_if_contact_exist(app)
    contact = Contact(firstname="YOYOYOYOYOYOOY", middlename="KEKEKEKEK")
    contact.id = old_contactss[0].id
    app.contacts.modify_first_contact(contact)
    new_contactss = app.contacts.get_contactss_list()
    assert len(old_contactss) == len(new_contactss)
    old_contactss[0] = contact
    assert sorted(old_contactss, key=Contact.id_or_max) == sorted(new_contactss, key=Contact.id_or_max)
コード例 #2
0
def test_modify_contact_firstname(app):
    if app.contacts.count() == 0:
        app.contacts.create(Contact(firstname="test"))
    old_contacts = app.contacts.get_contact_list()
    index = randrange(len(old_contacts))
    contact = Contact(firstname="Irina", lastname="Savina")
    contact.id = old_contacts[index].id
    app.contacts.modify_contact_by_index(index, contact)
    assert len(old_contacts) == app.contacts.count()
    new_contacts = app.contacts.get_contact_list()
    old_contacts[index] = contact
    assert sorted(old_contacts, key=Contact.id_or_max) == sorted(new_contacts, key=Contact.id_or_max)
コード例 #3
0
def test_edit_some_contact_name(app):
    if app.contacts.count() == 0:
        app.contacts.create(Contact(fir="Test"))
    old_cont = app.contacts.get_list()
    newC = Contact(fir="changed firstname")
    index = randrange(len(old_cont))
    # newC.id = old_cont[0].id
    # newC.las = old_cont[0].las
    app.contacts.edit_by_index(index, newC)
    new_cont = app.contacts.get_list()
    assert len(old_cont) == len(new_cont)
    old_cont[index].fir = newC.fir
    assert sorted(old_cont,
                  key=Contact.id_or_max) == sorted(new_cont,
                                                   key=Contact.id_or_max)
コード例 #4
0
ファイル: contact.py プロジェクト: poliakiwi/python_training
 def get_info_from_edit(self, index):
     wd = self.app.wd
     #open home page
     self.go_home()
     #click to edit
     self.open_edit_by_index(index)
     fir = wd.find_element_by_name("firstname").get_attribute("value")
     las = wd.find_element_by_name("lastname").get_attribute("value")
     id = wd.find_element_by_name("id").get_attribute("value")
     tel_1 = wd.find_element_by_name("home").get_attribute("value")
     tel_2 = wd.find_element_by_name("mobile").get_attribute("value")
     tel_3 = wd.find_element_by_name("work").get_attribute("value")
     hom_2 = wd.find_element_by_name("phone2").get_attribute("value")
     add_1 = wd.find_element_by_name("address").get_attribute("value")
     mail_1 = wd.find_element_by_name("email").get_attribute("value")
     mail_2 = wd.find_element_by_name("email2").get_attribute("value")
     mail_3 = wd.find_element_by_name("email3").get_attribute("value")
     return Contact(las=las,
                    fir=fir,
                    id=id,
                    tel_1=tel_1,
                    tel_2=tel_2,
                    tel_3=tel_3,
                    hom_2=hom_2,
                    add_1=add_1,
                    mail_1=mail_1,
                    mail_2=mail_2,
                    mail_3=mail_3)
コード例 #5
0
ファイル: contact_steps.py プロジェクト: ivans-dev/training
def non_empty_contact_list(db, app):
    if len(db.get_contact_list()) == 0:
        app.contact.create(
            Contact(firstname='some firstname',
                    middlename='some middlename',
                    lastname='some lastname'))
    return db.get_contact_list()
コード例 #6
0
def test_del_some_contact(app, db, check_ui):
    if len(db.get_contact_list()) == 0:
        app.contacts.create(Contact(fir="Test"))
    old_cont = db.get_contact_list()
    cont = random.choice(old_cont)
    app.contacts.del_by_id(cont.id)
    new_cont = db.get_contact_list()
    old_cont.remove(cont)
    assert old_cont == new_cont

    def clear_blank(s):
        s = re.sub(" +", " ", s)
        s = re.sub(" $", "", s)
        return s

    def clean(cont):
        return Contact(id=cont.id,
                       fir=clear_blank(cont.fir),
                       las=clear_blank(cont.las),
                       add_1=clear_blank(cont.add_1))

    if check_ui:
        ui_list = app.contacts.get_list()
        db_list = map(clean, new_cont)
        assert sorted(db_list,
                      key=Contact.id_or_max) == sorted(ui_list,
                                                       key=Contact.id_or_max)
コード例 #7
0
 def get_contacts_in_groups_list(self, group_id):
     orm_group = list(
         select(g for g in DBHelper.ORMGroup if g.id == group_id))[0]
     contacts = list()
     for contact in orm_group.contacts:
         contacts.append(
             Contact(contact.first_name, contact.middle_name,
                     contact.last_name, contact.id))
     return contacts
コード例 #8
0
def generate_contacts_data(num_of_elms):
    testdata = [
        Contact(random_string("name", 20), random_string("header", 20),
                random_string("footer", 20), None) for i in range(num_of_elms)
    ]
    file = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                        "../data/contacts.json")
    with open(file, "w") as f:
        f.write(jsonpickle.encode(testdata))
コード例 #9
0
 def get_contactss_list(self):
     wd = self.app.wd
     contactss = []
     for element in wd.find_elements_by_name("entry"):
         text = element.text
         id = element.find_element_by_name("selected[]").get_attribute(
             "value")
         contactss.append(Contact(firstname=text, lastname=text, id=id))
     return contactss
コード例 #10
0
def test_delete_first_contact(app):
    if app.contacts.count() == 0:
        app.contacts.create(Contact(firstname="test"))
    old_contacts = app.contacts.get_contact_list()
    index = randrange(len(old_contacts))
    app.contacts.delete_contact_by_index(index)
    assert len(old_contacts) - 1 == app.contacts.count()
    new_contacts = app.contacts.get_contact_list()
    old_contacts[index:index + 1] = []
    assert old_contacts == new_contacts
コード例 #11
0
 def get_contact_by_num(self, num):
     contact = self.wd.find_element_by_xpath("//tr[@name='entry'][" +
                                             str(num) + "]")
     elm_id = contact.find_element_by_css_selector("input").get_attribute(
         "id")
     elm_last_name = contact.find_element_by_css_selector(
         "td:nth-child(2)").text
     elm_first_name = contact.find_element_by_css_selector(
         "td:nth-child(3)").text
     return Contact(elm_first_name, None, elm_last_name, elm_id)
コード例 #12
0
def test_add_contact_to_group(app):
    app.contacts.create_contact_if_not_exist(Contact("TestFirstName", "TestMiddleName", "TestLastName", None))
    app.groups.create_group_if_not_exist(Group("ToRemoveName", "ToRemoveHeader", "ToRemoveFooter", None))
    app.navigation.to_contacts()
    contact_id = app.contacts.select_contact_by_num_and_get_id(0)
    group_id = app.contacts.add_contact_to_group_by_index_and_get_group_id(0)
    list_ids = list()
    for elm in app.orm.get_contacts_in_groups_list(group_id):
        list_ids.append(elm.elm_id)
    assert int(contact_id) in list_ids
コード例 #13
0
 def get_contacts_list(self):
     contacts = list()
     entity_contacts = list(
         select(g for g in DBHelper.ORMContact
                if g.deprecated.date().year == 0))
     for contact in entity_contacts:
         contacts.append(
             Contact(contact.first_name, contact.middle_name,
                     contact.last_name, contact.id))
     return contacts
コード例 #14
0
ファイル: contact.py プロジェクト: poliakiwi/python_training
 def get_info_from_view(self, index):
     wd = self.app.wd
     #open home page
     self.go_home()
     #click to edit
     self.view_by_index(index)
     text = wd.find_element_by_id("content").text
     tel_1 = re.search("H: (.*)", text).group(1)
     tel_2 = re.search("M: (.*)", text).group(1)
     tel_3 = re.search("W: (.*)", text).group(1)
     hom_2 = re.search("P: (.*)", text).group(1)
     return Contact(tel_1=tel_1, tel_2=tel_2, tel_3=tel_3, hom_2=hom_2)
コード例 #15
0
def test_modify_contact(app, check_ui):
    app.navigation.to_contacts()
    app.contacts.create_contact_if_not_exist(
        Contact("TestFirstName", "TestMiddleName", "TestLastName", None))
    app.navigation.to_contacts()
    if check_ui:
        old_contacts = app.contacts.get_contacts()
    else:
        old_contacts = app.orm.get_contacts_list()
    index = get_random_index_from_list(old_contacts)
    modified_contact = Contact("ModifiedFirstName", "ModifiedMiddleName",
                               "ModifiedLastName", None)
    app.contacts.modify_contact_by_num_on_page(modified_contact, index)
    app.navigation.to_contacts()
    if check_ui:
        new_contacts = app.contacts.get_contacts()
    else:
        new_contacts = app.orm.get_contacts_list()
    del old_contacts[index]
    old_contacts.append(modified_contact)
    assert len(old_contacts) == len(new_contacts)
    assert list_sort(new_contacts) == list_sort(old_contacts)
コード例 #16
0
def test_phones_and_other_info_on_home(app):
    if app.contacts.count() == 0:
        app.contacts.create(Contact(fir="Test"))
    cont_list = app.contacts.get_list()
    index = randrange(len(cont_list))
    contact_from_home = cont_list[index]
    contact_from_edit = app.contacts.get_info_from_edit(index)
    assert contact_from_home.all_tel_from_home == merge_tel(contact_from_edit)
    assert contact_from_home.fir == clear_blank(contact_from_edit.fir)
    assert contact_from_home.las == clear_blank(contact_from_edit.las)
    assert contact_from_home.add_1 == clear_blank(contact_from_edit.add_1)
    assert contact_from_home.all_mail_from_home == merge_mail(
        contact_from_edit)
コード例 #17
0
 def get_contacts(self):
     if self.contacts_cache is None:
         contacts = self.wd.find_elements_by_xpath("//tr[@name='entry']")
         self.contacts_cache = list()
         for elm in contacts:
             elm_id = elm.find_element_by_css_selector(
                 "input").get_attribute("id")
             elm_last_name = elm.find_element_by_css_selector(
                 "td:nth-child(2)").text
             elm_first_name = elm.find_element_by_css_selector(
                 "td:nth-child(3)").text
             self.contacts_cache.append(
                 Contact(elm_first_name, None, elm_last_name, elm_id))
         return list(self.contacts_cache)
     else:
         return list(self.contacts_cache)
コード例 #18
0
ファイル: db.py プロジェクト: poliakiwi/python_training
 def get_contact_list(self):
     listC = []
     cursor = self.connection.cursor()
     try:
         cursor.execute(
             "select id, firstname , lastname, address from addressbook where deprecated ='0000-00-00 00:00:00' "
         )
         for row in cursor:
             (id, firstname, lastname, address) = row
             listC.append(
                 Contact(id=str(id),
                         fir=firstname,
                         las=lastname,
                         add_1=address))
     finally:
         cursor.close()
     return listC
コード例 #19
0
ファイル: test_add_new_contact.py プロジェクト: PTsios/python
def test_add_new_blank_contact(app):
    old_contactss = app.contacts.get_contactss_list()
    contact = Contact(firstname="",
                      middlename="",
                      lastname="",
                      nickname="",
                      title="",
                      company="",
                      address="",
                      home="",
                      email="")
    app.contacts.adding_new_contact(contact)
    new_contactss = app.contacts.get_contactss_list()
    assert len(old_contactss) + 1 == len(new_contactss)
    old_contactss.append(contact)
    assert sorted(old_contactss,
                  key=Contact.id_or_max) == sorted(new_contactss,
                                                   key=Contact.id_or_max)
コード例 #20
0
ファイル: test_del_contact.py プロジェクト: PTsios/python
def test_deleting_contact(app):
    if app.contacts.edit_count() == 0:
        app.contacts.adding_new_contact(
            Contact(firstname="Pavel",
                    middlename="Notallowed",
                    lastname="Tsios",
                    nickname="raynalds",
                    title="QA",
                    company="devhouse",
                    address="Russia. Stavropol",
                    home="9175265472",
                    email="*****@*****.**"))
    old_contactss = app.contacts.get_contactss_list()
    app.contacts.deleting_one_contact()
    new_contactss = app.contacts.get_contactss_list()
    assert len(old_contactss) - 1 == len(new_contactss)
    old_contactss[0:1] = []
    assert old_contactss == new_contactss
コード例 #21
0
def test_remove_contact(app, check_ui):
    app.navigation.to_contacts()
    app.contacts.create_contact_if_not_exist(
        Contact("TestFirstName", "TestMiddleName", "TestLastName", None))
    if check_ui:
        old_contacts = app.contacts.get_contacts()
    else:
        old_contacts = app.orm.get_contacts_list()
    len_contacts = len(old_contacts)
    index = get_random_index_from_list(old_contacts)
    app.navigation.to_contacts()
    app.contacts.remove_contact_by_num_on_page(index)
    app.navigation.to_contacts()
    if check_ui:
        new_contacts = app.contacts.get_contacts()
    else:
        new_contacts = app.orm.get_contacts_list()
    assert len(new_contacts) == len_contacts - 1
    del old_contacts[index]
    assert list_sort(new_contacts) == list_sort(old_contacts)
コード例 #22
0
ファイル: contact.py プロジェクト: poliakiwi/python_training
 def get_list(self):
     wd = self.app.wd
     if self.cont_cache is None:
         self.go_home()
         self.cont_cache = []
         for element in wd.find_elements_by_css_selector(
                 "tr[name='entry']"):
             las = element.find_element_by_xpath("td[2]").text
             fir = element.find_element_by_xpath("td[3]").text
             add_1 = element.find_element_by_xpath("td[4]").text
             id = element.find_element_by_name("selected[]").get_attribute(
                 "value")
             all_mail = element.find_element_by_xpath("td[5]").text
             all_tel = element.find_element_by_xpath("td[6]").text
             self.cont_cache.append(
                 Contact(las=las,
                         fir=fir,
                         id=id,
                         add_1=add_1,
                         all_mail_from_home=all_mail,
                         all_tel_from_home=all_tel))
     return list(self.cont_cache)
コード例 #23
0
        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))])


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

testdata = [
    Contact(
        firstname="", lastname="", homephone="", mobilephone="", workphone="")
] + [
    Contact(firstname=random_string("firstname", 20),
            lastname=random_string("lastname", 20),
            homephone=random_string("homephone", 20),
            mobilephone=random_string("mobilephone", 20),
            workphone=random_string("workphone", 20)) 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))
コード例 #24
0
 def clean(cont):
     return Contact(id=cont.id,
                    fir=clear_blank(cont.fir),
                    las=clear_blank(cont.las),
                    add_1=clear_blank(cont.add_1))
コード例 #25
0
ファイル: contact_steps.py プロジェクト: ivans-dev/training
def new_contact(firstname, middlename, lastname):
    return Contact(firstname=firstname,
                   middlename=middlename,
                   lastname=lastname)
コード例 #26
0
ファイル: contact_steps.py プロジェクト: ivans-dev/training
def edited_contact(firstname, middlename, lastname):
    return Contact(firstname=firstname,
                   middlename=middlename,
                   lastname=lastname)
コード例 #27
0
from model.contacts import Contact


testdata = [
    Contact(firstname="firstname1", lastname="lastname1", homephone="homephone1",
            mobilephone="mobilephone1", workphone="workphone1"),
    Contact(firstname="firstname2", lastname="lastname2", homephone="homephone2",
            mobilephone="mobilephone2", workphone="workphone2")
]
コード例 #28
0
# -*- coding: utf-8 -*-
from model.contacts import Contact

testdata = [
    Contact(fir="fir1",
            mid="mid1",
            las="las1",
            nic="nic1",
            tit="tit1",
            com="com1",
            add_1="add1",
            tel_1="111",
            tel_2="222",
            tel_3="333",
            tel_4="444",
            mail_1="*****@*****.**",
            mail_2="*****@*****.**",
            mail_3="*****@*****.**",
            hom="hom1.ru",
            add_2="add2",
            hom_2="hom2",
            not_2="not2"),
    Contact(fir="fir2",
            mid="mid2",
            las="las2",
            nic="nic2",
            tit="tit2",
            com="com2",
            add_1="add2")
]
コード例 #29
0
def random_str(prefix, maxlen):
    sym = string.ascii_letters + string.digits + " " * 10  #+ string.punctuation
    return prefix + "".join(
        [random.choice(sym) for i in range(random.randrange(maxlen))])


testdata = [
    Contact(fir="",
            mid="",
            las="",
            nic="",
            tit="",
            com="",
            add_1="",
            tel_1="",
            tel_2="",
            tel_3="",
            tel_4="",
            mail_1="",
            mail_2="",
            mail_3="",
            hom="",
            add_2="",
            hom_2="",
            not_2="")
] + [
    Contact(fir=random_str("fir", 10),
            mid=random_str("mid", 10),
            las=random_str("las", 10),
            nic=random_str("nic", 10),
            tit=random_str("tit", 10),
            com=random_str("com", 10),
コード例 #30
0
def checking_if_contact_exist(app):
    if app.contacts.edit_count() == 0:
        app.contacts.adding_new_contact(Contact(firstname="Pavel", middlename="Notallowed", lastname="Tsios", nickname="raynalds", title="QA", company="devhouse", address="Russia. Stavropol", home="9175265472", email="*****@*****.**"))