def new_contact(firstname, middlename, lastname, nickname, title, company,
                homeaddress, homephone, mobilephone, workphone, faxphone,
                email, email2, email3, homepage, bday, bmonth, byear, aday,
                amonth, ayear, address2, phone2, notes):
    return ContactMainInfo(firstname=firstname,
                           middlename=middlename,
                           lastname=lastname,
                           nickname=nickname,
                           title=title,
                           company=company,
                           homeaddress=homeaddress,
                           homephone=homephone,
                           mobilephone=mobilephone,
                           workphone=workphone,
                           faxphone=faxphone,
                           email=email,
                           email2=email2,
                           email3=email3,
                           homepage=homepage,
                           bday=bday,
                           bmonth=bmonth,
                           byear=byear,
                           aday=aday,
                           amonth=amonth,
                           ayear=ayear,
                           address2=address2,
                           phone2=phone2,
                           notes=notes)
def test_first_name_on_home_page(app, db):
    if len(db.get_contact_list()) == 0:
        app.contact.create(
            ContactMainInfo(firstname="FirstNameTest",
                            middlename="MiddleNameTest",
                            lastname="LastNameTest",
                            nickname="NickNameTest",
                            title="TestTitle",
                            company="TestCompany",
                            homeaddress="Test Street Test home",
                            homephone="9998887766",
                            mobilephone="+79876543210",
                            workphone="+567",
                            faxphone="3456",
                            email="*****@*****.**",
                            email2="*****@*****.**",
                            email3="*****@*****.**",
                            homepage="hhtps://test.ru",
                            bday="1",
                            bmonth="July",
                            byear="1990",
                            aday="6",
                            amonth="November",
                            ayear="1987",
                            address2="Street address",
                            phone2="testhome",
                            notes="blablabla"))
    contacts_on_home_page = app.contact.get_contact_list()
    for contact in contacts_on_home_page:
        contacts_on_home_page_db = db.get_contact_list_main_info(contact.id)
        assert contact.firstname == contacts_on_home_page_db.firstname
def non_empty_contact_list(db, app):
    if len(db.get_contact_list()) == 0:
        app.contact.create(
            ContactMainInfo(firstname="FirstNameTest",
                            middlename="MiddleNameTest",
                            lastname="LastNameTest",
                            nickname="NickNameTest",
                            title="TestTitle",
                            company="TestCompany",
                            homeaddress="Test Street Test home",
                            homephone="9998887766",
                            mobilephone="+79876543210",
                            workphone="+567",
                            faxphone="3456",
                            email="*****@*****.**",
                            email2="*****@*****.**",
                            email3="*****@*****.**",
                            homepage="hhtps://test.ru",
                            bday="1",
                            bmonth="July",
                            byear="1990",
                            aday="6",
                            amonth="November",
                            ayear="1987",
                            address2="Street address",
                            phone2="testhome",
                            notes="blablabla"))
    return db.get_contact_list()
def test_add_contact_in_group_main_page(app, db, check_ui):
    contact = ContactMainInfo(firstname="FirstNameTest",
                              middlename="MiddleNameTest",
                              lastname="LastNameTest",
                              nickname="NickNameTest",
                              title="TestTitle",
                              company="TestCompany",
                              homeaddress="Test Street Test home",
                              homephone="9998887766",
                              mobilephone="+79876543210",
                              workphone="+567",
                              faxphone="3456",
                              email="*****@*****.**",
                              email2="*****@*****.**",
                              email3="*****@*****.**",
                              homepage="hhtps://test.ru",
                              bday="1",
                              bmonth="July",
                              byear="1990",
                              aday="6",
                              amonth="November",
                              ayear="1987",
                              address2="Street address",
                              phone2="testhome",
                              notes="blablabla")
    group = Group(name="TestName", header="TestHeader", footer="TestFooter")
    # Получить список групп
    group_list = db.get_group_list()
    if len(group_list) == 0:
        app.group.create(group)
        group_list = db.get_group_list()
    # Получить список контактов
    contact_list = db.get_contact_list()
    if len(contact_list) == 0:
        app.contact.create(contact)
        contact_list = db.get_contact_list()
    # Получить связь групп с контактами
    contacts_in_group = db.get_contacts_in_groups_list()
    # Проверить какие группы не привязаны к контактам (если нет таких, создать)
    group_non_contact = db.get_groups_not_in_contacts()
    if len(group_non_contact) == 0:
        app.group.create(group)
        group_non_contact = db.get_groups_not_in_contacts()
    # Проверить есть ли контакты без группы (если нет, создать)
    contacts_non_group = db.get_contacts_not_in_groups()
    if len(contacts_non_group) == 0:
        app.contact.create(contact)
        contacts_non_group = db.get_contacts_not_in_groups()
    # Привязать группу к контакту
    app.contact.connect_in_group(contacts_non_group[-1].id,
                                 group_non_contact[-1].id)
    contacts_in_group.append(
        ContactInGroup(id=contacts_non_group[-1].id,
                       group_id=group_non_contact[-1].id))
    # Проверить, что контакт привязан к группе
    assert sorted(db.get_contacts_in_groups_list(),
                  key=ContactInGroup.id_or_max) == sorted(
                      contacts_in_group, key=ContactInGroup.id_or_max)
Beispiel #5
0
 def get_contact_from_view_page(self, index):
     wd = self.app.wd
     self.open_contact_to_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)
     phone2 = re.search("P: (.*)", text).group(1)
     return ContactMainInfo(homephone=homephone, mobilephone=mobilephone, workphone=workphone, phone2=phone2)
Beispiel #6
0
 def get_contact_list(self):
     list = []
     cursor = self.connection.cursor()
     try:
         cursor.execute("select id, firstname, lastname from addressbook where deprecated='0000-00-00 00:00:00'")
         for row in cursor:
             (id, firstname, lastname) = row
             list.append(ContactMainInfo(id=str(id), firstname=firstname, lastname=lastname))
     finally:
         cursor.close()
     return list
Beispiel #7
0
 def get_contact_list_main_info(self, id):
     list = []
     cursor = self.connection.cursor()
     try:
         cursor.execute("select firstname, lastname, id, home, mobile, work, phone2, email, email2, email3 from addressbook where id='%s'" % id)
         for row in cursor:
             (firstname, lastname, id, home, mobile, work, phone2, email, email2, email3) = row
             list.append(ContactMainInfo(firstname=firstname, lastname=lastname, id=str(id), all_phones_from_home_page=clear(merge_phones_like_on_home_page([home, mobile, work, phone2])), all_emails_from_home_page=clear(merge_emails_like_on_home_page([email, email2, email3]))))
     finally:
         cursor.close()
     return list[0]
Beispiel #8
0
 def get_contacts_not_in_groups(self):
     list = []
     cursor = self.connection.cursor()
     try:
         cursor.execute("(SELECT c.id, c.firstname, c.lastname FROM addressbook c LEFT OUTER JOIN address_in_groups adingr ON c.id=adingr.id WHERE adingr.id is NULL) UNION ALL (SELECT c.id, c.firstname, c.lastname FROM addressbook c RIGHT OUTER JOIN address_in_groups adingr ON c.id=adingr.id WHERE c.id is NULL)")
         for row in cursor:
             (id, firstname, lastname) = row
             list.append(ContactMainInfo(id=str(id), firstname=firstname, lastname=lastname))
     finally:
         cursor.close()
     return list
Beispiel #9
0
def test_modify_contact_firstname(app, db, check_ui):
    if len(db.get_contact_list()) == 0:
        app.contact.create(
            ContactMainInfo(firstname="FirstNameTest",
                            middlename="MiddleNameTest",
                            lastname="LastNameTest",
                            nickname="NickNameTest",
                            title="TestTitle",
                            company="TestCompany",
                            homeaddress="Test Street Test home",
                            homephone="9998887766",
                            mobilephone="+79876543210",
                            workphone="+567",
                            faxphone="3456",
                            email="*****@*****.**",
                            email2="*****@*****.**",
                            email3="*****@*****.**",
                            homepage="hhtps://test.ru",
                            bday="1",
                            bmonth="July",
                            byear="1990",
                            aday="6",
                            amonth="November",
                            ayear="1987",
                            address2="Street address",
                            phone2="testhome",
                            notes="blablabla"))
    old_contacts = db.get_contact_list()
    contact_random = random.choice(old_contacts)
    contact = ContactMainInfo(firstname="First Name Test")
    app.contact.modify_contact_by_id(contact_random.id, contact)
    new_contacts = db.get_contact_list()
    assert len(old_contacts) == len(db.get_contact_list())
    old_contacts[old_contacts.index(
        contact_random)].firstname = contact.firstname
    assert sorted(old_contacts, key=ContactMainInfo.id_or_max) == sorted(
        new_contacts, key=ContactMainInfo.id_or_max)
    if check_ui:
        assert sorted(new_contacts, key=ContactMainInfo.id_or_max) == sorted(
            app.contact.get_contact_list(), key=ContactMainInfo.id_or_max)
def test_add_contact_in_group(app, db, check_ui):
    # Получить список групп
    group_list = db.get_group_list()
    contact = ContactMainInfo(firstname="FirstNameTest",
                              middlename="MiddleNameTest",
                              lastname="LastNameTest",
                              nickname="NickNameTest",
                              title="TestTitle",
                              company="TestCompany",
                              homeaddress="Test Street Test home",
                              homephone="9998887766",
                              mobilephone="+79876543210",
                              workphone="+567",
                              faxphone="3456",
                              email="*****@*****.**",
                              email2="*****@*****.**",
                              email3="*****@*****.**",
                              homepage="hhtps://test.ru",
                              bday="1",
                              bmonth="July",
                              byear="1990",
                              aday="6",
                              amonth="November",
                              ayear="1987",
                              address2="Street address",
                              phone2="testhome",
                              notes="blablabla")
    # Создать группу если групп нет
    if len(group_list) == 0:
        app.group.create(
            Group(name="TestName", header="TestHeader", footer="TestFooter"))
        group_list = db.get_group_list()
    # Выбрать рандомную группу
    group_name = random.choice(group_list)
    old_contacts = db.get_contact_list()
    old_contacts_in_group = db.get_contacts_in_groups_list()
    # Добавление контакта
    app.open_home_page()
    app.contact.create_in_group(contact, group_name.name)
    new_contacts = db.get_contact_list()
    old_contacts.append(contact)
    assert sorted(old_contacts, key=ContactMainInfo.id_or_max) == sorted(
        new_contacts, key=ContactMainInfo.id_or_max)
    old_contacts_in_group.append(
        ContactInGroup(id=new_contacts[-1].id, group_id=group_name.id))
    assert sorted(db.get_contacts_in_groups_list(),
                  key=ContactInGroup.id_or_max) == sorted(
                      old_contacts_in_group, key=ContactInGroup.id_or_max)
    if check_ui:
        assert sorted(new_contacts, key=ContactMainInfo.id_or_max) == sorted(
            app.contact.get_contact_list(), key=ContactMainInfo.id_or_max)
Beispiel #11
0
 def get_contact_info(self):
     wd = self.app.wd
     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")
     mobilephone = wd.find_element_by_name("mobile").get_attribute("value")
     workphone = wd.find_element_by_name("work").get_attribute("value")
     phone2 = wd.find_element_by_name("phone2").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")
     address = wd.find_element_by_name("address").get_attribute("value")
     return ContactMainInfo(id=id, firstname=firstname, lastname=lastname, homephone=homephone, mobilephone=mobilephone, workphone=workphone, phone2=phone2, email=email, email2=email2, email3=email3, homeaddress=address)
def test_delete_contact_in_group(app, db):
    # Получить список контактов в группе
    old_contacts_in_group = db.get_contacts_in_groups_list()
    group_list = db.get_group_list()
    contact = ContactMainInfo(firstname="FirstNameTest",
                              middlename="MiddleNameTest",
                              lastname="LastNameTest",
                              nickname="NickNameTest",
                              title="TestTitle",
                              company="TestCompany",
                              homeaddress="Test Street Test home",
                              homephone="9998887766",
                              mobilephone="+79876543210",
                              workphone="+567",
                              faxphone="3456",
                              email="*****@*****.**",
                              email2="*****@*****.**",
                              email3="*****@*****.**",
                              homepage="hhtps://test.ru",
                              bday="1",
                              bmonth="July",
                              byear="1990",
                              aday="6",
                              amonth="November",
                              ayear="1987",
                              address2="Street address",
                              phone2="testhome",
                              notes="blablabla")
    # Проверяем, есть ли привязанные контакты к группе. Если нет, добавляем
    if len(old_contacts_in_group) == 0:
        app.open_home_page()
        # Проверяем, есть ли вообще группы, если нет, добавляем
        if len(group_list) == 0:
            app.group.create(
                Group(name="TestName",
                      header="TestHeader",
                      footer="TestFooter"))
            group_list = db.get_group_list()
        group_name = random.choice(group_list)
        app.contact.create_in_group(contact, group_name.name)
        old_contacts_in_group = db.get_contacts_in_groups_list()
    # Выбрать группу, которая привязана к контакту
    select_group_in_contact_id = old_contacts_in_group[-1].group_id
    select_group_in_contact = old_contacts_in_group[-1]
    # Удалить группу
    app.group.delete_group_by_id(select_group_in_contact_id)
    # Сравнить
    old_contacts_in_group.remove(select_group_in_contact)
    new_contacts_in_group = db.get_contacts_in_groups_list()
    assert (old_contacts_in_group == new_contacts_in_group)
Beispiel #13
0
 def get_contact_list(self):
     if self.contact_cache is None:
         wd = self.app.wd
         self.open_contact_page()
         self.contact_cache = []
         count = len(wd.find_elements_by_xpath("//input[@name='selected[]']"))
         for i in range(2, count+2):
             lastname = wd.find_element_by_xpath("//tr[" + str(i) + "]//input[@name='selected[]']/../../td[2]").text
             firstname = wd.find_element_by_xpath("//tr[" + str(i) + "]//input[@name='selected[]']/../../td[3]").text
             id = wd.find_element_by_xpath("//tr[" + str(i) + "]//input[@name='selected[]']").get_attribute("value")
             all_phones = wd.find_element_by_xpath("//tr[" + str(i) + "]//input[@name='selected[]']/../../td[6]").text
             all_emails = wd.find_element_by_xpath("//tr[" + str(i) + "]//input[@name='selected[]']/../../td[5]").text
             address = wd.find_element_by_xpath("//tr[" + str(i) + "]//input[@name='selected[]']/../../td[4]").text
             self.contact_cache.append(ContactMainInfo(id=id, firstname=firstname, lastname=lastname, all_phones_from_home_page=clear(all_phones), all_emails_from_home_page=clear(all_emails), homeaddress=address))
     return list(self.contact_cache)
def test_delete_some_contact(app, db, check_ui):
    with allure.step("Given a non-empty contact list"):
        if len(db.get_contact_list()) == 0:
            app.contact.create(ContactMainInfo(firstname="TestFirstName"))
        old_contacts = db.get_contact_list()
    with allure.step("Given a random contact from the list"):
        contact = random.choice(old_contacts)
    with allure.step("When I delete the contact from the list"):
        app.contact.delete_contact_by_id(contact.id)
    with allure.step(
            "Then the new contact list is equal to the old contact list without the deleted contact"
    ):
        new_contacts = db.get_contact_list()
        assert len(old_contacts) - 1 == len(new_contacts)
        old_contacts.remove(contact)
        assert old_contacts == new_contacts
        if check_ui:
            assert sorted(new_contacts,
                          key=ContactMainInfo.id_or_max) == sorted(
                              app.contact.get_contact_list(),
                              key=ContactMainInfo.id_or_max)
Beispiel #15
0
 def convert(contact):
     return ContactMainInfo(id=str(contact.id),
                            firstname=contact.firstname,
                            lastname=contact.lastname)
Beispiel #16
0
def test_modify_contact(app, db, check_ui):
    with allure.step("Given a non-empty contact list"):
        if len(db.get_contact_list()) == 0:
            app.contact.create(
                ContactMainInfo(firstname="FirstNameTest",
                                middlename="MiddleNameTest",
                                lastname="LastNameTest",
                                nickname="NickNameTest",
                                title="TestTitle",
                                company="TestCompany",
                                homeaddress="Test Street Test home",
                                homephone="9998887766",
                                mobilephone="+79876543210",
                                workphone="+567",
                                faxphone="3456",
                                email="*****@*****.**",
                                email2="*****@*****.**",
                                email3="*****@*****.**",
                                homepage="hhtps://test.ru",
                                bday="1",
                                bmonth="July",
                                byear="1990",
                                aday="6",
                                amonth="November",
                                ayear="1987",
                                address2="Street address",
                                phone2="testhome",
                                notes="blablabla"))
        old_contacts = db.get_contact_list()
    with allure.step("Given a random contact from the list"):
        contact_random = random.choice(old_contacts)
    contact = ContactMainInfo(firstname="1",
                              middlename="2",
                              lastname="3",
                              nickname="4",
                              title="5",
                              company="6",
                              homeaddress="7",
                              homephone="",
                              mobilephone="",
                              workphone="333",
                              faxphone="35677",
                              email="*****@*****.**",
                              email2="*****@*****.**",
                              email3="*****@*****.**",
                              homepage="hhtps://21test.ru",
                              bday="1",
                              bmonth="July",
                              byear="1990",
                              aday="6",
                              amonth="November",
                              ayear="1987",
                              address2="3",
                              phone2="4",
                              notes="5")
    with allure.step("When I modify the contact from the list"):
        app.contact.modify_contact_by_id(contact_random.id, contact)
    with allure.step("Then the contact has been replaced in the contact list"):
        new_contacts = db.get_contact_list()
        assert len(old_contacts) == len(db.get_contact_list())
        old_contacts[old_contacts.index(
            contact_random)].firstname = contact.firstname
        old_contacts[old_contacts.index(
            contact_random)].lastname = contact.lastname
        assert sorted(old_contacts, key=ContactMainInfo.id_or_max) == sorted(
            new_contacts, key=ContactMainInfo.id_or_max)
        if check_ui:
            assert sorted(new_contacts,
                          key=ContactMainInfo.id_or_max) == sorted(
                              app.contact.get_contact_list(),
                              key=ContactMainInfo.id_or_max)
Beispiel #17
0
         for i in range(random.randrange(maxlen))]) + "@mail.ru"


testdata = [
    ContactMainInfo(firstname=random_string("firstname", 15),
                    middlename=random_string("middlename", 15),
                    lastname=random_string("lastname", 15),
                    nickname=random_string("nickname", 10),
                    title=random_string("title", 20),
                    company=random_string("company", 25),
                    homeaddress=random_string("homeaddress", 20),
                    homephone=random_dijits("+", 11),
                    mobilephone=random_dijits("+", 11),
                    workphone=random_dijits("+", 15),
                    faxphone=random_dijits("+", 7),
                    email=random_email("email", 5),
                    email2=random_email("email", 5),
                    email3=random_email("email", 5),
                    homepage=random_string("https://", 15),
                    bday="1",
                    bmonth="July",
                    byear="1990",
                    aday="6",
                    amonth="November",
                    ayear="1987",
                    address2=random_string("address2", 25),
                    phone2=random_dijits("+", 11),
                    notes=random_string("notes", 30)) for i in range(5)
]

file = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", f)
print("Path: " + f + " , " + file)