コード例 #1
0
def test_modify_kontact_firstname(app, db, check_ui):
    if len(db.get_kontact_list()) == 0:
        app.kontact.create(Kontact(firstname="test"))
    old_kontacts = db.get_kontact_list()
    kontact = random.choice(old_kontacts)
    kontact_mod = Kontact(firstname="Test_contact!!!")
    app.kontact.modify_kontact_by_id(kontact.id, kontact_mod)
    assert len(old_kontacts) == app.kontact.count()
    new_kontacts = db.get_kontact_list()
    assert sorted(old_kontacts,
                  key=Kontact.id_or_max) == sorted(new_kontacts,
                                                   key=Kontact.id_or_max)
    if check_ui:
        assert sorted(new_kontacts, key=Kontact.id_or_max) == sorted(
            app.kontact.get_kontact_list(), key=Kontact.id_or_max)
コード例 #2
0
 def get_kontact_from_view_page(self, index):
     wd = self.app.wd
     self.open_kontact_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 Kontact(home=home, mobile=mobile, work=work, phone2=phone2)
コード例 #3
0
def test_delete_some_kontact(app,db,check_ui):
    if len(db.get_kontact_list()) == 0:
        app.kontact.create(Kontact(firstname="test"))
    old_kontacts = db.get_kontact_list()
    kontact = random.choice(old_kontacts)
    app.kontact.delete_kontact_by_id(kontact.id)
    assert len(old_kontacts) - 1 == app.kontact.count()
    new_kontacts = db.get_kontact_list()
    old_kontacts.remove(kontact) #написать метод
    assert old_kontacts == new_kontacts
    if check_ui:
        assert sorted(new_kontacts, key=Kontact.id_or_max) == sorted(app.kontact.get_kontact_list(),key=Kontact.id_or_max)
コード例 #4
0
def test_all_user_info_on_homepage_by_index(app):
    if app.kontact.count() == 0:
        app.kontact.create(Kontact(firstname="test", lastname="test"))
    kontacts = app.kontact.get_kontact_list()
    index = randrange(len(kontacts))
    print(index)
    kontact_from_homepage = app.kontact.get_kontact_list()[index]
    kontact_from_edit_page = app.kontact.get_kontact_info_from_edit_page(index)
    assert kontact_from_homepage.all_phones_from_homepage == merge_phones_like_on_home_page(
        kontact_from_edit_page)
    assert kontact_from_homepage.all_email_from_homepage == merge_email_like_on_home_page(
        kontact_from_edit_page)
    assert kontact_from_homepage.firstname == kontact_from_edit_page.firstname
    assert kontact_from_homepage.lastname == kontact_from_edit_page.lastname
コード例 #5
0
def test_check_info_on_home_page_and_in_db(app, db):
    if app.kontact.count() == 0:
        app.kontact.create(Kontact(firstname="test", lastname="test"))
    list_kontakts_on_homepage = app.kontact.get_kontact_list()
    list_kontakts_from_bd = db.get_kontact_list()

    for kontact in range(
            len(sorted(list_kontakts_on_homepage, key=Kontact.id_or_max))):
        kontact_home_page = sorted(list_kontakts_on_homepage,
                                   key=Kontact.id_or_max)[kontact]
        kontact_from_bd = sorted(list_kontakts_from_bd,
                                 key=Kontact.id_or_max)[kontact]

        assert kontact_home_page.all_email_from_homepage == merge_email_like_on_home_page(
            kontact_from_bd)
        assert kontact_home_page.all_phones_from_homepage == merge_phones_like_on_home_page(
            kontact_from_bd)
        assert kontact_home_page.id == kontact_from_bd.id
        assert kontact_home_page.firstname == kontact_from_bd.firstname
        assert kontact_home_page.lastname == kontact_from_bd.lastname
コード例 #6
0
 def get_kontact_list(self):
     if self.kontact_cache is None:
         wd = self.app.wd
         self.go_to_home_page()
         self.kontact_cache = []
         for element in wd.find_elements_by_name("entry"):
             id = element.find_element_by_name("selected[]").get_attribute(
                 "value")
             list_td = element.find_elements_by_tag_name("td")
             lastname = list_td[1].text
             firstname = list_td[2].text
             all_phones = list_td[5].text
             all_email = list_td[4].text
             self.kontact_cache.append(
                 Kontact(id=id,
                         firstname=firstname,
                         lastname=lastname,
                         all_phones_from_homepage=all_phones,
                         all_email_from_homepage=all_email))
     return list(self.kontact_cache)
コード例 #7
0
 def get_kontact_info_from_edit_page(self, index):
     wd = self.app.wd
     self.open_kontact_to_edit_by_index(index)
     firstname = 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")
     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 Kontact(firstname=firstname,
                    lastname=lastname,
                    id=id,
                    home=home,
                    mobile=mobile,
                    work=work,
                    phone2=phone2,
                    email=email,
                    email2=email2,
                    email3=email3)
コード例 #8
0
ファイル: db.py プロジェクト: tets20/pytest_training_repo
 def get_kontact_list(self):
     list = []
     cursor = self.connection.cursor()
     try:
         cursor.execute(
             "select id, firstname, lastname, email, email2, email3, home ,mobile ,work, phone2 from addressbook where deprecated='0000-00-00 00:00:00'"
         )
         for row in cursor:
             (id, firstname, lastname, email, email2, email3, home, mobile,
              work, phone2) = row
             list.append(
                 Kontact(id=str(id),
                         firstname=firstname,
                         lastname=lastname,
                         email=email,
                         email2=email2,
                         email3=email3,
                         home=home,
                         mobile=mobile,
                         work=work,
                         phone2=phone2))
     finally:
         cursor.close()
     return list
コード例 #9
0
ファイル: orm.py プロジェクト: tets20/pytest_training_repo
 def convert(kontact):
     return Kontact(id=str(kontact.id), firstname=kontact.firstname, lastname=kontact.lastname)
コード例 #10
0
# -*- coding: utf-8 -*-

from model.kontact import Kontact

Testdata = [
    Kontact(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",
            byear="byear1",
            ayear="ayear1",
            address2="address21",
            phone2="phone21",
            notes="notes1"),
    Kontact(firstname="firstname2",
            middlename="middlename2",
            lastname="lastname2",
            nickname="nickname2",
            title="title2",
            company="company2",
コード例 #11
0
    symbols = string.ascii_letters + string.digits + string.punctuation + " " * 10
    return prefix + "".join(
        [random.choice(symbols) for i in range(random.randrange(maxlen))])


Testdata = [
    Kontact(firstname="",
            middlename="",
            lastname="",
            nickname="",
            title="",
            company="",
            address="",
            home="",
            mobile="",
            work="",
            fax="",
            email="",
            email2="",
            email3="",
            homepage="",
            byear="",
            ayear="",
            address2="",
            phone2="",
            notes="")
] + [
    Kontact(firstname=random_string("firstname", 4),
            middlename=random_string("middlename", 4),
            lastname=random_string("lastname", 4),
            nickname=random_string("nickname", 5),
            title=random_string("title", 5),