def test_edit_contact(app, db, check_ui):
    with allure.step('Given a non-empty contact list'):
        if len(db.get_contact_list()) == 0:
            app.contact.add_new(Contact(firstname="Ekaterina", middlename="Aleksandrovna", lastname="Pentjuhina",
                                        nickname="kate_penti", title="ttl", company="company", address="Kolomna",
                                        mobilephone="8-111-111-11-11", email="*****@*****.**", homepage="hmpg.net",
                                        address2="address", phone2="home-phone", notes="notes", bday="14", bmonth="October",
                                        byear="1991", aday="1", amonth="January", ayear="2010"))
        old_contacts = db.get_contact_list()
    with allure.step('Given a random contact from the list'):
        contact = random.choice(old_contacts)
    with allure.step("Given new contact's data"):
        update_contact = Contact(firstname="Katerina", middlename="Aleksandrovna", lastname="Pentjuhina",
                          nickname="kate_penti", title="ttl", company="company", address="Kolomna",
                          mobilephone="8-111-111-11-11", email="*****@*****.**", homepage="hmpg.net",
                          address2="address", phone2="home-phone", notes="notes")
    with allure.step("When I modify the contact's properties"):
        app.contact.edit_contact_by_id(contact.id, update_contact)
    with allure.step('Then the new contact list is equal to the old contact list with the modified contact'):
        new_contacts = db.get_contact_list()
        assert len(old_contacts) == len(new_contacts)
        index = old_contacts.index(contact)
        old_contacts[index] = update_contact
        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)
예제 #2
0
 def get_contact_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),
                         firstname=firstname,
                         lastname=lastname,
                         address=address,
                         homephone=home,
                         mobilephone=mobile,
                         workphone=work,
                         phone2=phone2,
                         email=email,
                         email2=email2,
                         email3=email3))
     finally:
         cursor.close()
     return list
 def get_contact_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")
     id = wd.find_element_by_name("id").get_attribute("value")
     address = wd.find_element_by_name("address").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")
     secondaryphone = 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")
     return Contact(firstname=firstname,
                    lastname=lastname,
                    id=id,
                    address=address,
                    homephone=homephone,
                    mobilephone=mobilephone,
                    workphone=workphone,
                    phone2=secondaryphone,
                    email=email,
                    email2=email2,
                    email3=email3)
 def get_contacts_in_group(self, group_id):
     wd = self.app.wd
     self.app.open_home_page()
     self.filter_contacts_by_group(group_id)
     contacts_in_group = []
     for element in wd.find_elements_by_css_selector("tr[name=entry]"):
         firstname = element.find_element_by_css_selector(
             "td:nth-child(3)").text
         lastname = element.find_element_by_css_selector(
             "td:nth-child(2)").text
         id = element.find_element_by_name("selected[]").get_attribute(
             "value")
         address = element.find_element_by_css_selector(
             "td:nth-child(4)").text
         all_phones = element.find_element_by_css_selector(
             "td:nth-child(6)").text
         all_emails = element.find_element_by_css_selector(
             "td:nth-child(5)").text
         contacts_in_group.append(
             Contact(firstname=firstname,
                     lastname=lastname,
                     id=id,
                     address=address,
                     all_phones_from_home_page=all_phones,
                     all_emails_from_home_page=all_emails))
     return contacts_in_group
 def get_contact_list(self):
     if self.contact_cache is None:
         wd = self.app.wd
         self.app.open_home_page()
         self.contact_cache = []
         for element in wd.find_elements_by_css_selector("tr[name=entry]"):
             firstname = element.find_element_by_css_selector(
                 "td:nth-child(3)").text
             lastname = element.find_element_by_css_selector(
                 "td:nth-child(2)").text
             id = element.find_element_by_name("selected[]").get_attribute(
                 "value")
             address = element.find_element_by_css_selector(
                 "td:nth-child(4)").text
             all_phones = element.find_element_by_css_selector(
                 "td:nth-child(6)").text
             all_emails = element.find_element_by_css_selector(
                 "td:nth-child(5)").text
             self.contact_cache.append(
                 Contact(firstname=firstname,
                         lastname=lastname,
                         id=id,
                         address=address,
                         all_phones_from_home_page=all_phones,
                         all_emails_from_home_page=all_emails))
     return list(self.contact_cache)
 def get_contact_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)
     mobilephone = re.search("M: (.*)", text).group(1)
     workphone = re.search("W: (.*)", text).group(1)
     secondaryphone = re.search("P: (.*)", text).group(1)
     return Contact(homephone=homephone,
                    mobilephone=mobilephone,
                    workphone=workphone,
                    phone2=secondaryphone)
예제 #7
0
def update_contact():
    return Contact(firstname="Katerina",
                   middlename="Aleksandrovna",
                   lastname="Pentjuhina",
                   nickname="kate_penti",
                   title="ttl",
                   company="company",
                   address="Kolomna",
                   mobilephone="8-111-111-11-11",
                   email="*****@*****.**",
                   homepage="hmpg.net",
                   address2="address",
                   phone2="home-phone",
                   notes="notes")
예제 #8
0
def new_contact(firstname, lastname, middlename, nickname, title, company,
                homephone, mobilephone, workphone, phone2, email, homepage,
                address):
    return Contact(firstname=firstname,
                   lastname=lastname,
                   middlename=middlename,
                   nickname=nickname,
                   title=title,
                   company=company,
                   homephone=homephone,
                   mobilephone=mobilephone,
                   workphone=workphone,
                   phone2=phone2,
                   email=email,
                   homepage=homepage,
                   address=address)
예제 #9
0
def non_empty_contact_list(db, app):
    if len(db.get_contact_list()) == 0:
        app.contact.add_new(
            Contact(firstname="firstname1",
                    lastname="lastname1",
                    middlename="middlename1",
                    nickname="nickname1",
                    title="title1",
                    company="company1",
                    homephone="11-11-11",
                    mobilephone="11-11-11",
                    workphone="1111-11",
                    phone2="11-11-11",
                    email="*****@*****.**",
                    homepage="homepage.net",
                    address="address1"))
    return db.get_contact_list()
예제 #10
0
def test_delete_contact_from_edit_form(app, db, check_ui):
    with allure.step('Given a non-empty contact list'):
        if len(db.get_contact_list()) == 0:
            app.contact.add_new(Contact(firstname="Ekaterina", middlename="Aleksandrovna", lastname="Pentjuhina",
                                        nickname="kate_penti", title="ttl", company="company", address="Kolomna",
                                        mobilephone="8-111-111-11-11", email="*****@*****.**", homepage="hmpg.net",
                                        address2="address", phone2="home-phone", notes="notes", bday="14", bmonth="October",
                                        byear="1991", aday="1", amonth="January", ayear="2010"))
        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_from_edit_form(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()
        old_contacts.remove(contact)
        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)
예제 #11
0
def test_add_contact_to_group(app, orm):
    if len(orm.get_contact_list()) == 0:
        app.contact.add_new(Contact(firstname="Ekaterina", middlename="Aleksandrovna", lastname="Pentjuhina",
                                    nickname="kate_penti", title="ttl", company="company", address="Kolomna",
                                    mobilephone="8-111-111-11-11", email="*****@*****.**", homepage="hmpg.net",
                                    address2="address", phone2="home-phone", notes="notes", bday="14", bmonth="October",
                                    byear="1991", aday="1", amonth="January", ayear="2010"))
    all_contacts = orm.get_contact_list()
    contact = random.choice(all_contacts)
    if len(orm.get_group_list()) == 0:
        app.group.create(Group(name="test group"))
    all_groups = orm.get_group_list()
    group = random.choice(all_groups)
    if contact in orm.get_contacts_in_group(group):
        # удалить контакт из группы
        app.contact.delete_contact_from_group(group.id, contact.id)
    # добавить контакт к группе
    app.contact.add_contact_to_group(contact.id, group.id)
    contacts_in_group = orm.get_contacts_in_group(group)
    contacts_in_group_ui = app.contact.get_contacts_in_group(group.id)
    assert sorted(contacts_in_group_ui, key=Contact.id_or_max) == sorted(contacts_in_group, key=Contact.id_or_max)
예제 #12
0
 def convert(contact):
     return Contact(id=str(contact.id),
                    firstname=contact.firstname,
                    lastname=contact.lastname)
예제 #13
0
    symbols = string.ascii_letters
    return "".join([random.choice(symbols) for i in range(random.randrange(maxlen))])


def random_digit(maxlen):
    digits = string.digits
    return "".join([random.choice(digits) for i in range(random.randint(5, maxlen))])


def random_mix_string(maxlen, postfix):
    symbols = string.ascii_letters + string.digits
    return "".join([random.choice(symbols) for i in range(random.randrange(maxlen))]) + postfix


testdata = [
    Contact(firstname=random_string(10), lastname=random_string(15), middlename=random_string(15),
            nickname=random_string(7), title=random_string(15), company=random_string(15),
            homephone=random_digit(11), mobilephone=random_digit(11), workphone=random_digit(11), phone2=random_digit(11),
            email=random_mix_string(10, "@mail.ru"), homepage=random_mix_string(10, ".net"),
            address=random_string(20))
    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)
    out.write(jsonpickle.encode(testdata))

from model.contact_properties import Contact

testdata = [
    Contact(firstname="firstname1",
            lastname="lastname1",
            middlename="middlename1",
            nickname="nickname1",
            title="title1",
            company="company1",
            homephone="111",
            mobilephone="111",
            workphone="111",
            phone2="111",
            email="*****@*****.**",
            homepage="111.net",
            address="address1"),
    Contact(firstname="firstname2",
            lastname="lastname2",
            middlename="middlename2",
            nickname="nickname2",
            title="title2",
            company="company2",
            homephone="222",
            mobilephone="222",
            workphone="222",
            phone2="222",
            email="*****@*****.**",
            homepage="222.net",
            address="address2")
]
 def new_contact(self, firstname, lastname, middlename):
     return Contact(firstname=firstname,
                    lastname=lastname,
                    middlename=middlename)