Пример #1
0
 def get_contact_list(self):
     list = []
     cursor = self.connection.cursor()
     try:
         cursor.execute(
             "select id, firstname, middlename, lastname, nickname, company, title, address, home, "
             "mobile, work, fax, email, email2, email3, homepage, address2, phone2,"
             "notes from addressbook")
         for row in cursor:
             (id, firstname, middlename, lastname, nickname, company, title,
              address, home, mobile, work, fax, email, email2, email3,
              homepage, address2, phone2, notes) = row
             list.append(
                 NewContact(id=str(id),
                            first_name=firstname,
                            middle_name=middlename,
                            last_name=lastname,
                            nick_name=nickname,
                            company=company,
                            tittle=title,
                            address1=address,
                            home_phone=home,
                            mobile_phone=mobile,
                            work_phone=work,
                            fax=fax,
                            email1=email,
                            email2=email2,
                            email3=email3,
                            homepage=homepage,
                            address2=address2,
                            phone2=phone2,
                            notes=notes))
     finally:
         cursor.close()
     return list
Пример #2
0
 def get_contact_info_from_edit_page(self, index):
     browser = self.app.browser
     self.open_contact_to_edit_by_index(index)
     firstname = browser.find_element(By.NAME,
                                      "firstname").get_attribute("value")
     lastname = browser.find_element(By.NAME,
                                     "lastname").get_attribute("value")
     address = browser.find_element(By.NAME, "address").text
     email1 = browser.find_element(By.NAME, "email").get_attribute("value")
     email2 = browser.find_element(By.NAME, "email2").get_attribute("value")
     email3 = browser.find_element(By.NAME, "email3").get_attribute("value")
     homephone = browser.find_element(By.NAME,
                                      "home").get_attribute("value")
     mobilephone = browser.find_element(By.NAME,
                                        "mobile").get_attribute("value")
     workphone = browser.find_element(By.NAME,
                                      "work").get_attribute("value")
     secondaryphone = browser.find_element(By.NAME,
                                           "phone2").get_attribute("value")
     id = browser.find_element(By.NAME, "id").get_attribute("value")
     return NewContact(first_name=firstname,
                       last_name=lastname,
                       address1=address,
                       email1=email1,
                       email2=email2,
                       email3=email3,
                       home_phone=homephone,
                       mobile_phone=mobilephone,
                       work_phone=workphone,
                       phone2=secondaryphone,
                       id=id)
Пример #3
0
 def get_contact_list(self):
     if self.contact_cashe is None:
         browser = self.app.browser
         self.open_home()
         self.contact_cashe = []
         for elements in browser.find_elements(By.NAME, "entry"):
             cells = elements.find_elements(
                 By.TAG_NAME, "td")  # Данная точка найтёт текст
             id = cells[0].find_element(By.TAG_NAME,
                                        "input").get_attribute("value")
             last_text = cells[1].text
             first_text = cells[2].text
             address = cells[3].text
             all_email = cells[4].text
             all_phones = cells[5].text
             self.contact_cashe.append(
                 NewContact(
                     last_name=last_text,
                     first_name=first_text,
                     address1=address,
                     all_phones_from_home_page=all_phones,
                     all_email_from_home_page=all_email,
                     id=id,
                 ))
     return list(self.contact_cashe)
 def clean(contact):
     return NewContact(
         id=contact.id,
         first_name=contact.first_name.strip(),
         last_name=contact.last_name.strip(),
         address1=contact.address1.strip(),
         all_phones_from_home_page=merge_phones_like_on_home_page(contact),
         all_email_from_home_page=merge_email_like_on_home_page(contact))
Пример #5
0
 def get_contact_from_view_page(self, index):
     browser = self.app.browser
     self.open_contact_view_index(index)
     text = browser.find_element(By.ID, "content").text
     homephone = re.search("H: (.*)", text).group(1)
     mobilephone = re.search("M: (.*)", text).group(1)
     workphone = re.search("W: (.*)", text).group(1)
     secondaryphone = re.search("P: (.*)", text).group(1)
     return NewContact(home_phone=homephone,
                       mobile_phone=mobilephone,
                       work_phone=workphone,
                       phone2=secondaryphone,
                       id=id)
def test_modification_first_contact_address1(app, db, check_ui):
    if app.contact.count() == 0:
        app.contact.create_new_contact(
            NewContact(first_name="Victor",
                       middle_name="Ivan",
                       last_name="Petrov",
                       nick_name="Fox140",
                       tittle="test",
                       company="testcompany",
                       address1="Moscow",
                       home_phone="8(495)2154536",
                       mobile_phone="+79168956384",
                       work_phone="8-499-9576135",
                       fax="No",
                       email1="*****@*****.**",
                       email2="*****@*****.**",
                       email3="*****@*****.**",
                       homepage="testhomepage.ru",
                       bday="14",
                       bmonth="August",
                       byear="1987",
                       aday="24",
                       amonth="October",
                       ayear="2014",
                       address2="Moscow, Lenina 2",
                       phone2="8 456 9535956",
                       notes="Test Moscow information"))
    old_contact = db.get_contact_list()
    contact = random.choice(old_contact)
    mod_contact = NewContact(first_name="Petya", last_name="Petrov")
    app.contact.modification_contact_by_id(contact.id, mod_contact)
    assert len(old_contact) == app.contact.count()
    new_contacts = db.get_contact_list()
    assert len(old_contact) == len(new_contacts)
    if check_ui:
        assert sorted(old_contact, key=NewContact.id_or_max) == \
               sorted(app.group.get_group_list(), key=NewContact.id_or_max)
def test_add_contact_to_group(app, orm):
    if len(app.contact.get_contact_list()) == 0:
        app.contact.create_new_contact(NewContact(first_name="Red21", last_name="Gena"))
    if len(app.group.get_group_list()) == 0:
        app.group.create(Group(name="name33", header="headre23"))
    all_contacts = orm.get_contact_list()
    contact = random.choice(all_contacts)
    group_without_contacts = orm.get_groups_not_containing_contact(contact)
    if len(group_without_contacts) == 0:
        app.group.create(Group(name="name45", header="header90"))
        group_without_contacts = orm.get_groups_not_containing_contact(contact)
    group = random.choice(group_without_contacts)
    app.contact.add_contact_to_group_by_id(contact.id, group.id, group.name)
    contacts_in_group = orm.get_contacts_in_group(group)
    assert contact in contacts_in_group
Пример #8
0
 def convert(contact):
     return NewContact(id=str(contact.id),
                       first_name=contact.firstname,
                       middle_name=contact.middlename,
                       last_name=contact.lastname,
                       nick_name=contact.nickname,
                       company=contact.company,
                       tittle=contact.title,
                       address1=contact.address,
                       home_phone=contact.home,
                       mobile_phone=contact.mobile,
                       work_phone=contact.work,
                       fax=contact.fax,
                       email1=contact.email,
                       email2=contact.email2,
                       email3=contact.email3,
                       homepage=contact.homepage,
                       address2=contact.address2,
                       phone2=contact.phone2,
                       notes=contact.notes)
Пример #9
0
from model.contact import NewContact

contact_data = [
    NewContact(first_name="Victor",
               middle_name="Ivan",
               last_name="Petrov",
               nick_name="Fox140",
               tittle="test",
               company="testcompany",
               address1="Moscow",
               home_phone="8(495)2154536",
               mobile_phone="+79168956384",
               work_phone="8-499-9576135",
               fax="85663654556",
               email1="*****@*****.**",
               email2="*****@*****.**",
               email3="*****@*****.**",
               homepage="testhomepage.ru",
               bday="14",
               bmonth="August",
               byear="1987",
               aday="24",
               amonth="October",
               ayear="2014",
               address2="Moscow, Lenina 2",
               phone2="8 456 9535956",
               notes="Test Moscow information"),
    NewContact(first_name="Gena",
               middle_name="Kolya",
               last_name="Smirnov",
               nick_name="lis144",
def non_empty_contact_list(db, app):
    if len(db.get_group_list()) == 0:
        app.contact.create_new_contact(NewContact(last_name="test name"))
    return db.get_contact_list()
def new_contact(last_name, first_name, address1):
    return NewContact(last_name=last_name,
                      first_name=first_name,
                      address1=address1)
Пример #12
0
        [random.choice(symbols) for i in range(random.randrange(max_len))])


contact_date = [
    NewContact(first_name=random_string("First", 10),
               last_name=random_string("Last", 10),
               middle_name=random_string("Middle", 10),
               nick_name=random_string("nick", 10),
               company=random_string("Company", 20),
               tittle=random_string("Title", 20),
               address1=random_symbols("Omskaya", 20),
               home_phone=random_phone(11),
               mobile_phone=random_phone(11),
               work_phone=random_phone(11),
               fax=random_phone(11),
               email1=random_email(6),
               email2=random_email(6),
               email3=random_email(6),
               homepage=random_email(8),
               bday="15",
               bmonth="May",
               byear="1978",
               aday="25",
               amonth="June",
               ayear="2007",
               address2=random_symbols("Lenina", 20),
               phone2=random_phone(11),
               notes=random_symbols("Notes", 20)) for i in range(n)
]

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