Esempio n. 1
0
def test_edit_contact(app, db, check_ui):
    if (len(db.get_contact_list()) == 0):
        app.contact.new_contact_creation(
            Contact(firstname="Test_Firstname",
                    middlename="Test_Middlename",
                    lastname="Test_lastname",
                    nickname="Test_Nickname",
                    title="Test_title",
                    company="Company",
                    address="Test_adress",
                    home="Home",
                    mobile="mobile",
                    work="Test_work",
                    fax="Test_fax",
                    email="Test_email",
                    email1="Test_email1",
                    email2="Test_email2",
                    email3="Test_email3",
                    address2="Test_adress2",
                    homepage="Test_homepage",
                    bday="5",
                    bmounth="July",
                    byear="1982",
                    aday="2",
                    amonth="July",
                    ayear="2003",
                    phone2="Test_phone2",
                    notes="Test_notes"))
    old_contacts = db.get_contact_list()
    contact = Contact(firstname="test_by_check_edit",
                      middlename="test_by_check_edit",
                      lastname="test_by_check_edit",
                      nickname="test_by_check_edit",
                      title="test_by_check_edit",
                      company="test_by_check_edit",
                      address="test_by_check_edit",
                      home="test_by_check_edit",
                      mobile="test_by_check_edit",
                      work="test_by_check_edit",
                      fax="test_by_check_edit",
                      email="test_by_check_edit",
                      email1="test_by_check_edit",
                      email2="test_by_check_edit",
                      email3="test_by_check_edit",
                      address2="test_by_check_edit",
                      homepage="test_by_check_edit",
                      bday="5",
                      bmounth="July",
                      byear="1982",
                      aday="2",
                      amonth="July",
                      ayear="2003",
                      phone2="test_by_check_edit",
                      notes="test_by_check_edit")
    contact_random = random.choice(old_contacts)
    app.contact.edit_contact_by_id(contact, contact_random.id)
    new_contacts = db.get_contact_list()
    if (check_ui):
        assert sorted(new_contacts, key=Contact.id_or_max) == sorted(
            app.contact.get_contact_list(), key=Contact.id_or_max)
Esempio n. 2
0
 def data_edit_page_id(self, id):
     wd = self.app.wd
     self.get_edit_page_id(id)
     firstname = wd.find_element_by_xpath(
         "//input[@name='firstname']").get_attribute("value")
     lastname = wd.find_element_by_xpath(
         "//input[@name='lastname']").get_attribute("value")
     address = wd.find_element_by_xpath(
         "//textarea[@name='address']").get_attribute("value")
     home = wd.find_element_by_xpath("//input[@name='home']").get_attribute(
         "value")
     mobile = wd.find_element_by_xpath(
         "//input[@name='mobile']").get_attribute("value")
     work = wd.find_element_by_xpath("//input[@name='work']").get_attribute(
         "value")
     phone2 = wd.find_element_by_xpath(
         "//input[@name='phone2']").get_attribute("value")
     email = wd.find_element_by_xpath(
         "//input[@name='email']").get_attribute("value")
     email1 = wd.find_element_by_xpath(
         "//input[@name='email2']").get_attribute("value")
     email2 = wd.find_element_by_xpath(
         "//input[@name='email3']").get_attribute("value")
     return Contact(firstname=firstname,
                    lastname=lastname,
                    address=address,
                    home=home,
                    mobile=mobile,
                    work=work,
                    phone2=phone2,
                    email=email,
                    email1=email1,
                    email2=email2)
Esempio n. 3
0
    def get_contact_list(self):
        list = []
        id_list = []
        cursor = self.connection.cursor()
        try:
            cursor.execute(
                "select id, company, firstname, lastname, email, email2, email3, home, mobile, work, phone2, address from addressbook"
            )
            for row in cursor:
                (id, company, firstname, lastname, email, email2, email3, home,
                 mobile, work, phone2, address) = row
                all_emails = "\n".join([email, email2, email3])
                all_phones = "\n".join([home, mobile, work, phone2])
                id_list.append(id)

                list.append(
                    Contact(id=str(id),
                            firstname=firstname,
                            lastname=lastname,
                            all_emails=all_emails,
                            all_phones=all_phones,
                            address=address))
                #id_list.append(Contact(id=str(id)))
        finally:
            cursor.close()
        return list
Esempio n. 4
0
 def in_com_p(self):
     with open('contacts.json', 'r', encoding='utf8') as file:
         data_print = json.load(file)
         for contact in data_print:
             print('***')
             print(
                 Contact(contact['Name'], contact['Surname'],
                         contact['Phone_num'], contact['Fav'],
                         *contact['Add info'], **contact['Add info 2']))
Esempio n. 5
0
 def in_com_pf(self):
     with open('contacts.json', 'r', encoding='utf8') as file:
         data = json.load(file)
         i = 0
         for contact in data:
             if contact['Fav'] == '1':
                 print(
                     Contact(contact['Name'], contact['Surname'],
                             contact['Phone_num'], contact['Fav'],
                             *contact['Add info'], **contact['Add info 2']))
             i += 1
Esempio n. 6
0
 def in_com_fio(self):
     in_name = input('Введите имя ')
     in_surname = input('Введите фамилию ')
     with open('contacts.json', 'r', encoding='utf8') as file:
         data = json.load(file)
         i = 0
         for contact in data:
             if (contact['Name'] == in_name) and (contact['Surname']
                                                  == in_surname):
                 print(
                     Contact(contact['Name'], contact['Surname'],
                             contact['Phone_num'], contact['Fav'],
                             *contact['Add info'], **contact['Add info 2']))
             i += 1
def test_add_contact_to_group(app):
    if (len(db.get_contact_list()) == 0):
        app.contact.new_contact_creation(
            Contact(firstname="Test_Firstname", middlename="Test_Middlename", lastname="Test_lastname",
                    nickname="Test_Nickname", title="Test_title", company="Company", address="Test_adress", home="Home",
                    mobile="mobile",
                    work="Test_work", fax="Test_fax", email="Test_email", email1="Test_email1", email2="Test_email2",
                    email3="Test_email3", address2="Test_adress2", homepage="Test_homepage", bday="5", bmounth="July",
                    byear="1982", aday="2", amonth="July", ayear="2003", phone2="Test_phone2", notes="Test_notes"))
    if app.group.count() == 0:
        app.group.create_group(Group(name="username", header="testheader", footer="testfooter"))

    if db.get_related_group_contact() == False:
        free_contact, free_group = db.get_not_related_group_contact()
        app.contact.add_contact_to_group(free_contact, str(free_group))

    related_contact, related_group = db.get_related_group_contact()
    app.contact.delete_contact_from_group(related_contact, str(related_group))
    assert str(related_contact) not in db.get_list_id_contact_in_group(Group(id=related_group))
Esempio n. 8
0
def main():
    phone_book_1 = PhoneBook('phone_book_1')  # создали телефонную книгу
    in_com = input(
        'Введите команду: 1) A - для добавления контакта 2) P - для вывода контактов из книги '
        '3) D - для удаления контакта 4) PF - для выдачи всех избранных номеров  '
        '5)FIO - для поиска по имени и фамилии ')
    if in_com == 'A':
        contact_info = in_com_a()
        new_contact = Contact(contact_info[0], contact_info[1],
                              contact_info[2], contact_info[3],
                              *contact_info[4], **contact_info[5])
        phone_book_1.add_contact(new_contact)
        print(new_contact)
    elif in_com == 'P':
        phone_book_1.in_com_p()
    elif in_com == 'D':
        phone_book_1.in_com_d()
    elif in_com == 'PF':
        phone_book_1.in_com_pf()
    elif in_com == 'FIO':
        phone_book_1.in_com_fio()
Esempio n. 9
0
 def get_contact_list(self):
     if self.contact_cache is None:
         wd = self.app.wd
         self.app.open_homepage()
         self.contact_cache = []
         for row in wd.find_elements_by_name("entry"):
             cells = row.find_elements_by_tag_name("td")
             id = cells[0].find_element_by_tag_name("input").get_attribute(
                 "value")
             firstname = cells[2].text
             lastname = cells[1].text
             address = cells[3].text
             all_emails = cells[4].text
             all_phones = cells[5].text
             self.contact_cache.append(
                 Contact(firstname=firstname,
                         lastname=lastname,
                         id=id,
                         address=address,
                         all_phones=all_phones,
                         all_emails=all_emails))
     return list(self.contact_cache)
Esempio n. 10
0
 def convert(contact):
     return Contact(id=str(contact.id),
                    firstname=contact.firstname,
                    lastname=contact.lastname,
                    email=contact.email,
                    company=contact.company)
Esempio n. 11
0
    symbols = string.ascii_letters + string.digits
    return prefix + '_'.join(
        [random.choice(symbols) for i in range(random.randrange(maxlen))])


test_data = [
    Contact(firstname=random_string("firstname", 15),
            middlename=random_string("middlename", 10),
            lastname=random_string("lastname", 20),
            nickname=random_string("nickname", 13),
            title=random_string("title", 12),
            company=random_string("company", 11),
            address=random_string("address", 14),
            home=random_string("home", 21),
            mobile=random_string("mobile", 10),
            work=random_string("work", 11),
            fax=random_string("fax", 10),
            email=random_string("email", 18),
            email1=random_string("email1", 12),
            email2=random_string("email2", 21),
            email3=random_string("email3", 10),
            address2=random_string("address2", 17),
            homepage=random_string("homepage", 14),
            phone2=random_string("phone2", 10),
            notes=random_string("notes", 14)) for i 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)