Exemple #1
0
 def contact_info_from_edit_page(self, index):
     wd = self.app.wd
     self.app.open_home_page()
     self.select_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")
     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")
     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 Contacts(firstname=firstname,
                     lastname=lastname,
                     id=id,
                     homephone=homephone,
                     mobilephone=mobilephone,
                     workphone=workphone,
                     secondaryphone=secondaryphone,
                     address=address,
                     email=email,
                     email2=email2,
                     email3=email3)
Exemple #2
0
 def get_contact_list(self):
     contact_list = []
     cursor = self.connection.cursor()
     try:
         cursor.execute(
             "select id, firstname, lastname, email, email2, email3, address, work, home, phone2, mobile from addressbook where deprecated ='0000-00-00 00:00:00'"
         )
         for row in cursor:
             (id, firstname, lastname, email, email2, email3, address, work,
              home, phone2, mobile) = row
             contact_list.append(
                 Contacts(id=str(id),
                          firstname=firstname,
                          lastname=lastname,
                          email=email,
                          email2=email2,
                          email3=email3,
                          address=address,
                          workphone=work,
                          homephone=home,
                          secondaryphone=phone2,
                          mobilephone=mobile))
     finally:
         cursor.close()
     return contact_list
 def clean(contact):
     return Contacts(
         id=contact.id,
         firstname=contact.firstname.strip(),
         lastname=contact.lastname.strip(),
         address=contact.address.strip(),
         all_emails_from_home_page=(contact.email + contact.email2 +
                                    contact.email3).strip(),
         all_phones_from_home_page=(contact.homephone +
                                    contact.mobilephone +
                                    contact.workphone +
                                    contact.secondaryphone).strip())
Exemple #4
0
def test_del_contact(app,db,check_ui):
    if len (db.get_contact_list()) == 0:
        app.contacts.add(Contacts(firstname='Vasya', lastname='Pupkin', initials='VP'))
    old_contacts = db.get_contact_list()
    contact = random.choice(old_contacts)
    app.contacts.delete_contact_by_id(contact.id)
    assert len(old_contacts) - 1 == app.contacts.count()
    old_contacts.remove(contact)
    new_contacts = db.get_contact_list()
    assert old_contacts == new_contacts
    if check_ui:
        assert sorted(new_contacts, key=Contacts.id_or_max) == sorted(app.contacts.get_group_list(), key=Contacts.id_or_max)
def test_modify_contacts_first_name(app, db, check_ui):
    if len(db.get_contact_list()) == 0:
        contacts = Contacts(firstname='Igor', lastname='Petro')
        app.contacts.add(contacts)
    with pytest.allure.step('Given a contact list'):
        old_contacts = db.get_contact_list()
    with pytest.allure.step('Given a random contact from the list'):
        contact = random.choice(old_contacts)
    modified_contact = Contacts(firstname='1sad', lastname='edited')
    modified_contact.id = contact.id
    with pytest.allure.step(
            'When I modify the contact with id %s from the list with %s contact data'
            % (contact.id, modified_contact)):
        app.contacts.modify_contact_by_id(contact.id, modified_contact)
    with pytest.allure.step(
            'Then list with modified contact list is equal to the old list with not modified contact'
    ):
        new_contacts = db.get_contact_list()
        assert len(old_contacts) == app.contacts.count()
        if check_ui:
            assert sorted(new_contacts, key=Contacts.id_or_max) == sorted(
                app.contacts.get_contact_list(), key=Contacts.id_or_max)
Exemple #6
0
 def get_contact_from_view_page(self, index):
     wd = self.app.wd
     self.view_contact_profile_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)
     fax = re.search("F: (.*)", text).group(1)
     secondaryphone = re.search("P: (.*)", text).group(1)
     return Contacts(id=id,
                     homephone=homephone,
                     mobilephone=mobilephone,
                     workphone=workphone,
                     secondaryphone=secondaryphone)
Exemple #7
0
 def get_contact_list(self):
     if self.contact_cache is None:
         wd = self.app.wd
         self.wait("addressbook/", "maintable")
         self.contact_cache = []
         for element in wd.find_elements_by_name("entry"):
             cells = element.find_elements_by_tag_name("td")
             id = cells[0].find_element_by_tag_name("input").get_attribute(
                 "value")
             address = cells[3].text
             all_phones = cells[5].text
             all_emails = cells[4].text
             firstname = cells[2].text
             lastname = cells[1].text
             self.contact_cache.append(
                 Contacts(firstname=firstname,
                          lastname=lastname,
                          address=address,
                          id=id,
                          all_phones_from_home_page=all_phones,
                          all_emails_from_home_page=all_emails))
     return list(self.contact_cache)
def modify_contact(app, random_contact):
    app.contacts.modify_contact_by_id(
        random_contact.id, Contacts(firstname='Lin', lastname='Quer'))
def non_empty_contact_list(db, app):
    if len(db.get_contact_list()) == 0:
        app.contacts.add(Contacts(firstname='Vasia', lastname='Vetrov'))
    return db.get_contact_list()
def new_contact(firstname, lastname, nickname):
    return Contacts(firstname=firstname, lastname=lastname, nickname=nickname)
Exemple #11
0
from Model.contacts import Contacts

testdata_static = [
    Contacts(firstname='ALex',
             lastname='Progeq',
             nickname='alexP',
             mobilephone='12838754',
             workphone='1123-1123',
             email='alex#[email protected]',
             address='New York 1293Av,app#12'),
    Contacts(firstname='ALex',
             lastname='Progeq',
             nickname='alexP',
             mobilephone='12838754',
             workphone='1123-1123',
             email='alex#[email protected]',
             address='New York 1293Av,app#12')
]
Exemple #12
0
 def convert(contact):
     return Contacts(id=str(contact.id), firstname=contact.firstname, lastname=contact.lastname)
Exemple #13
0
    elif digits != None:
        digits = string.digits + "-" * 3
        return prefix + "".join(
            [random.choice(digits) for i in range(random.randrange(maxlen))])
    else:
        all = string.ascii_letters + string.digits + string.punctuation + " " * 10
        return prefix + "".join(
            [random.choice(all) for i in range(random.randrange(maxlen))])


testdata = [
    Contacts(firstname=random_string('name', 10),
             lastname=random_string('s_name', 7),
             nickname=random_string('n_name', 6, symbols=1),
             homephone=random_string('phone', 5, digits=1),
             workphone=random_string('w_phone', 5, digits=1),
             mobilephone=random_string('m_phone', 5, digits=1),
             fax=random_string('n_name', 6, digits=1),
             secondaryphone=random_string('s_phone', 6, digits=1),
             address=random_string('address', 6),
             address2=random_string('address2', 6),
             email=random_string('mail1@', 6),
             email2=random_string('mail2@', 6),
             email3=random_string('mail3@', 6)) for x 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))