def test_edit_address(app, db, check_ui):
    if len(db.get_address_list()) == 0:
        app.address.add_new_element(Contact(nick_name="Test"), Birthday(),
                                    Company())
    old_address = db.get_address_list()
    contact_to_change = random.choice(old_address)
    index_contact_to_change = old_address.index(contact_to_change)
    contact = Contact(id=contact_to_change.id,
                      first_name="First_N2",
                      middle_name="Middle_N2",
                      last_name="Last_N2",
                      nick_name="Nick_N2",
                      homephone="1101019",
                      mobilephone="+79119119199",
                      workphone="1100009",
                      secondaryphone="1100019",
                      e_mail="*****@*****.**",
                      address="Spb, Change Street 10")
    app.address.edit_element_by_id(contact_to_change.id, contact, Birthday(),
                                   Company())
    assert len(old_address) == app.address.count()
    old_address.remove(contact_to_change)
    old_address.insert(index_contact_to_change, contact)
    new_address = db.get_address_list()
    assert old_address == new_address
    if check_ui:
        db_list = map(app.address.clean, new_address)
        assert sorted(db_list, key=Contact.id_or_max) == sorted(
            app.address.get_address_list(), key=Contact.id_or_max)
Пример #2
0
 def get_address_list(self):
     list = []
     cursor = self.connection.cursor()
     try:
         cursor.execute(
             "select id, firstname, lastname, address, home, mobile, work, phone2, email, email2, email3 from addressbook where deprecated = '0000-00-00 00:00:00'"
         )
         for row in cursor:
             (id, firstname, lastname, address, home, mobile, work, phone2,
              email, email2, email3) = row
             list.append(
                 Contact(id=str(id),
                         first_name=str(firstname),
                         last_name=str(lastname),
                         address=str(address),
                         homephone=str(home),
                         mobilephone=str(mobile),
                         workphone=str(work),
                         secondaryphone=str(phone2),
                         e_mail=str(email),
                         e_mail2=str(email2),
                         e_mail3=str(email3)))
     finally:
         cursor.close()
     return list
Пример #3
0
 def get_address_info_from_edit_page(self, index):
     wd = self.app.wd
     self.open_contact_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")
     address = wd.find_element_by_name("address").get_attribute("value")
     id = wd.find_element_by_name("id").get_attribute("value")
     homephone = wd.find_element_by_name("home").get_attribute("value")
     workphone = wd.find_element_by_name("work").get_attribute("value")
     mobilephone = wd.find_element_by_name("mobile").get_attribute("value")
     secondaryphone = wd.find_element_by_name("phone2").get_attribute(
         "value")
     e_mail = wd.find_element_by_name("email").get_attribute("value")
     e_mail2 = wd.find_element_by_name("email2").get_attribute("value")
     e_mail3 = wd.find_element_by_name("email3").get_attribute("value")
     return Contact(first_name=firstname,
                    last_name=lastname,
                    id=id,
                    address=address,
                    homephone=homephone,
                    mobilephone=mobilephone,
                    workphone=workphone,
                    secondaryphone=secondaryphone,
                    e_mail=e_mail,
                    e_mail2=e_mail2,
                    e_mail3=e_mail3)
Пример #4
0
 def get_address_info_from_view_page(self, index):
     wd = self.app.wd
     self.open_contact_view_by_index(index)
     text = wd.find_element_by_id("content").text
     homephone = re.search("H: (.*)", text).group(1)
     workphone = re.search("W: (.*)", text).group(1)
     mobilephone = re.search("M: (.*)", text).group(1)
     secondaryphone = re.search("P: (.*)", text).group(1)
     return Contact(homephone=homephone,
                    mobilephone=mobilephone,
                    workphone=workphone,
                    secondaryphone=secondaryphone)
def test_del_some_address(app, orm, check_ui):
    if len(orm.get_address_list()) == 0:
        app.address.add_new_element(Contact(nick_name="Test"), Birthday(),
                                    Company())
    old_address = orm.get_address_list()
    address = random.choice(old_address)
    app.address.delete_address_by_id(address.id)
    old_address.remove(address)
    new_address = orm.get_address_list()
    assert old_address == new_address
    if check_ui:
        db_list = map(app.address.clean, new_address)
        assert sorted(db_list, key=Contact.id_or_max) == sorted(
            app.address.get_address_list(), key=Contact.id_or_max)
Пример #6
0
 def get_address_list(self):
     if self.address_cache is None:
         wd = self.app.wd
         self.go_home_page()
         self.address_cache = []
         for element in wd.find_elements_by_xpath(
                 "//table[@id='maintable']/tbody/tr[@name='entry']"):
             id = element.find_element_by_name("selected[]").get_attribute(
                 "value")
             cell = element.find_elements_by_tag_name("td")
             text_LN = cell[1].text
             text_FN = cell[2].text
             address = cell[3].text
             all_e_mails = cell[4].text
             all_phones = cell[5].text
             self.address_cache.append(
                 Contact(first_name=text_FN,
                         last_name=text_LN,
                         id=id,
                         address=address,
                         all_phones_from_home_page=all_phones,
                         all_e_mails_from_home_page=all_e_mails))
     return list(self.address_cache)
Пример #7
0
 def convert(contact):
     return Contact(id=str(contact.id),
                    first_name=contact.first_name,
                    last_name=contact.last_name)
Пример #8
0
        [random.choice(symbols) for i in range(random.randrange(maxlen))])


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


testdata = [
    Contact(first_name="",
            middle_name="",
            last_name="",
            nick_name="",
            homephone="",
            mobilephone="",
            workphone="",
            secondaryphone="",
            e_mail="",
            e_mail2="",
            e_mail3="",
            address="")
] + [
    Contact(first_name=random_string("Fname", 10),
            middle_name=random_string("Mname", 10),
            last_name=random_string("Lname", 10),
            nick_name=random_string("Nname", 10),
            homephone=random_phone("HP", 10),
            mobilephone=random_phone("MP", 10),
            workphone=random_phone("WP", 10),
            secondaryphone=random_phone("SP", 10),
            e_mail=random_email("1", 10),
Пример #9
0
 def clean(self, contact):
     return Contact(id=contact.id,
                    first_name=contact.first_name.strip(),
                    last_name=contact.last_name.strip())