def test_modify_some_contact(app, db, check_ui):
    if len(db.get_contact_list()) == 0:
        app.contact.create_new_contact(
            Contact(firstname='Stepan',
                    middlename='Barantsev',
                    lastname='Lol',
                    nickname='Bloodes',
                    email1='*****@*****.**'))
    old_contacts = db.get_contact_list()
    new_cont = Contact(firstname='Mi',
                       middlename='Lul',
                       lastname='Cat',
                       nickname='bars',
                       email1='*****@*****.**')
    cont = random.choice(old_contacts)
    new_cont.id = cont.id
    app.contact.modify_contact_by_id(new_cont, cont.id)
    new_contacts = db.get_contact_list()
    old_contacts.remove(cont)
    old_contacts.append(new_cont)
    assert sorted(old_contacts,
                  key=Contact.id_or_max) == sorted(new_contacts,
                                                   key=Contact.id_or_max)
    if check_ui:
        assert sorted(new_contacts, key=Contact.id_or_max) == sorted(
            app.contact.get_contact_list(), key=Contact.id_or_max)
Exemplo n.º 2
0
 def convert(contact):
     return Contact(firstname=contact.firstname, lastname=contact.lastname, id=str(contact.id), homephone=contact.homephone,
                mobilephone=contact.mobilephone, workphone=contact.workphone, secondaryphone=contact.secondaryphone,
                email1=contact.email1, email2=contact.email2, email3=contact.email3, address=contact.address,
                middlename=contact.middlename,
                nickname=contact.nickname, title=contact.title, company=contact.company,
                homepage=contact.homepage, notes=contact.notes, fax=contact.fax)
Exemplo n.º 3
0
    def get_contact_list(self):
        cursor = self.connection.cursor()
        s = []
        try:
            cursor.execute(
                "select id, firstname, middlename, lastname, nickname, company, title, address, "
                "home, mobile, work, fax, email, email2, email3, homepage, "
                "notes, phone2  from addressbook where deprecated='0000-00-00 00:00:00'"
            )
            for row in cursor:
                id, firstname, middlename,  lastname, nickname, company, title, address,\
                homephone, mobilephone, workphone, fax, email, email2, email3, homepage, notes, secondaryphone = row

                s.append(
                    Contact(firstname=firstname,
                            lastname=lastname,
                            id=str(id),
                            homephone=homephone,
                            mobilephone=mobilephone,
                            workphone=workphone,
                            secondaryphone=secondaryphone,
                            email1=email,
                            email2=email2,
                            email3=email3,
                            address=address,
                            middlename=middlename,
                            nickname=nickname,
                            title=title,
                            company=company,
                            homepage=homepage,
                            notes=notes,
                            fax=fax))
        finally:
            cursor.close()
        return s
Exemplo n.º 4
0
 def get_contact_info_from_edit_page(self, index):
     driver = self.app.driver
     self.app.open_home_page()
     self.open_contact_to_edit_by_index(index)
     firstname = driver.find_element_by_name('firstname').get_attribute(
         'value')
     lastname = driver.find_element_by_name('lastname').get_attribute(
         'value')
     address = driver.find_element_by_name("address").get_attribute("value")
     id = driver.find_element_by_name('id').get_attribute('value')
     email = driver.find_element_by_name("email").get_attribute("value")
     email2 = driver.find_element_by_name("email2").get_attribute("value")
     email3 = driver.find_element_by_name("email3").get_attribute("value")
     homephone = driver.find_element_by_name('home').get_attribute('value')
     mobilephone = driver.find_element_by_name('mobile').get_attribute(
         'value')
     workphone = driver.find_element_by_name('work').get_attribute('value')
     secondaryphone = driver.find_element_by_name('phone2').get_attribute(
         'value')
     middlename = driver.find_element_by_name('middlename').get_attribute(
         'value')
     nickname = driver.find_element_by_name('nickname').get_attribute(
         'value')
     title = driver.find_element_by_name('title').get_attribute('value')
     company = driver.find_element_by_name('company').get_attribute('value')
     homepage = driver.find_element_by_name('homepage').get_attribute(
         'value')
     notes = driver.find_element_by_name('notes').get_attribute('value')
     fax = driver.find_element_by_name('fax').get_attribute('value')
     return Contact(firstname=firstname,
                    lastname=lastname,
                    id=id,
                    homephone=homephone,
                    mobilephone=mobilephone,
                    workphone=workphone,
                    secondaryphone=secondaryphone,
                    email1=email,
                    email2=email2,
                    email3=email3,
                    address=address,
                    middlename=middlename,
                    nickname=nickname,
                    title=title,
                    company=company,
                    homepage=homepage,
                    notes=notes,
                    fax=fax)
Exemplo n.º 5
0
def test_delete_some_contact(app, db, check_ui):
    if len(db.get_contact_list()) == 0:
        app.contact.create_new_contact(
            Contact(firstname='Stepan',
                    middlename='Barantsev',
                    lastname='Lol',
                    nickname='Bloodes',
                    email1='*****@*****.**'))
    old_contacts = db.get_contact_list()
    cont = random.choice(old_contacts)
    app.contact.delete_contact_by_id(cont.id)
    new_contacts = db.get_contact_list()
    old_contacts.remove(cont)
    assert old_contacts == new_contacts
    if check_ui:
        assert sorted(new_contacts, key=Contact.id_or_max) == sorted(
            app.contact.get_contact_list(), key=Contact.id_or_max)
Exemplo n.º 6
0
 def get_contact_list(self):
     if self.cont_cashe == None:
         driver = self.app.driver
         self.app.open_home_page()
         self.cont_cashe = []
         for row in driver.find_elements_by_name("entry"):
             cells = row.find_elements_by_tag_name("td")
             id = row.find_element_by_css_selector(
                 'input[name="selected[]"]').get_attribute('value')
             firstname = cells[2].text
             lastname = cells[1].text
             address = cells[3].text
             allemails = cells[4].text
             all_phones = cells[5].text
             self.cont_cashe.append(
                 Contact(firstname=firstname,
                         lastname=lastname,
                         id=id,
                         all_phones_from_homepage=all_phones,
                         address=address,
                         allemails=allemails))
     return list(self.cont_cashe)
def test_add_contact_to_group(app, db):
    contact_list = db.get_contact_list()
    if len(contact_list) == 0:
        app.contact.create_new_contact(
            Contact(firstname="FF", lastname="HH", nickname="bbb"))
        contact_list = db.get_contact_list()
    group_list = db.get_group_list()
    if len(group_list) == 0:
        app.group.create_new_group(
            Group(group_name="New group",
                  group_header='Zez',
                  group_footer='Freytr'))
        group_list = db.get_group_list()
    contact = random.choice(contact_list)
    group = random.choice(group_list)
    contacts_in_group = db.get_contacts_in_group(group)
    app.contact.add_contact_to_group(contact, group)
    new_contacts_in_group = db.get_contacts_in_group(group)
    contacts_in_group.append(contact)
    assert sorted(contacts_in_group,
                  key=Contact.id_or_max) == sorted(new_contacts_in_group,
                                                   key=Contact.id_or_max)
    assert contact in db.get_contacts_in_group(group)
    assert contact not in db.get_contacts_not_in_group(group)
Exemplo n.º 8
0
def test_delete_contact_from_group(app, db):

    contact_list = db.get_contact_list()
    if len(contact_list) == 0:
        app.contact.create_new_contact(
            Contact(firstname="FF", lastname="HH", nickname="bbb"))
        contact_list = db.get_contact_list()
    group_list = db.get_group_list()
    if len(group_list) == 0:
        app.group.create_new_group(
            Group(group_name="New group",
                  group_header='Zez',
                  group_footer='Freytr'))
        group_list = db.get_group_list()

    all_groups = list(gr for gr in db.get_group_list()
                      if len(db.get_contacts_in_group(gr)))

    if not all_groups:
        contact = random.choice(contact_list)
        group = random.choice(group_list)
        app.contact.add_contact_to_group(contact, group)
        all_groups = list(gr for gr in db.get_group_list()
                          if len(db.get_contacts_in_group(gr)))

    group = random.choice(all_groups)
    all_contacts = db.get_contacts_in_group(group)
    contact = random.choice(all_contacts)
    app.contact.delete_contact_from_group(contact, group)
    all_contacts.remove(contact)
    all_new_contacts = db.get_contacts_in_group(group)
    assert sorted(all_new_contacts,
                  key=Contact.id_or_max) == sorted(all_contacts,
                                                   key=Contact.id_or_max)
    assert contact not in db.get_contacts_in_group(group)
    assert contact in db.get_contacts_not_in_group(group)
Exemplo n.º 9
0
from models.model_contact import Contact

testdata = [
    Contact(firstname='Stepan',
            middlename='Barantsev',
            lastname='Lol',
            nickname='Bloodes',
            email1='*****@*****.**'),
    Contact(firstname='pop',
            middlename='lv',
            lastname='Lwww',
            nickname='BWgggggg',
            email1='rgffgfgfgfgfg')
]
Exemplo n.º 10
0
 def get_contact_from_view_page(self, index):
     driver = self.app.driver
     self.open_contact_view_by_index(index)
     all_inf = driver.find_element_by_css_selector(
         'div#content').text  # Тут все данные считываются лопатой
     return Contact(all_information=all_inf)