def test_update_contact_from_details_page(app, db, check_ui):
    # Prepare before test
    app.contact.prepare_contact_test_suite()
    # Prepare old contact data
    contact = Contact(firstname="Ann", middlename="AT", lastname="Arner", nickname="Tee")
    contact.set_company_data(title="MegaMailGroutOfAllWorld", company="MegaMailGroupOfAllWorldCorporation")
    contact.set_address(address="somewhere beyond the sea")
    contact.set_emails(first="*****@*****.**",
                       second="*****@*****.**", third="*****@*****.**")
    contact.set_homepage("www.somewherebeyondthesea.com")
    contact.set_phones(home="112223366", mobile="+7(000)9999911111222", work="44444433", fax="2300011",
                       second_phone="+123331212")
    contact.set_second_info(address="World 36", notes="She is my friend")
    contact.set_birthday(day="4", month="4", year="1987")
    contact.set_anniversary(day="31", month="7", year="2010")
    # Create contacts
    app.contact.create(contact)
    old_contacts = app.contact.get_all_contacts()
    # Update contact
    app.contact.update_contact_from_details_page(1, None)
    new_contact = Contact("", "", "", "")
    new_contact.id = old_contacts[0].id
    # Check contacts list
    old_contacts[0] = new_contact
    new_contacts = db.get_contact_list()
    app.contact.check_if_contacts_are_equal(old_contacts, new_contacts)
    if check_ui:
        new_contacts = app.contact.get_all_contacts()
        app.contact.check_if_contacts_are_equal(old_contacts, new_contacts)
 def get_data_from_fields(self):
     contact_id = self.get_string_field_value("id")
     firstname = self.get_string_field_value("firstname")
     middlename = self.get_string_field_value("middlename")
     lastname = self.get_string_field_value("lastname")
     nickname = self.get_string_field_value("nickname")
     company = self.get_string_field_value("company")
     title = self.get_string_field_value("title")
     address = self.get_string_field_value("address")
     home = self.get_string_field_value("home")
     mobile = self.get_string_field_value("mobile")
     work = self.get_string_field_value("work")
     fax = self.get_string_field_value("fax")
     email = self.get_string_field_value("email")
     email2 = self.get_string_field_value("email2")
     email3 = self.get_string_field_value("email3")
     homepage = self.get_string_field_value("homepage")
     address2 = self.get_string_field_value("address2")
     phone2 = self.get_string_field_value("phone2")
     notes = self.get_string_field_value("notes")
     contact_data = Contact(firstname=firstname, middlename=middlename, lastname=lastname,
                            nickname=nickname, id=contact_id)
     contact_data.set_company_data(title=title, company=company)
     contact_data.set_address(address=address)
     contact_data.set_second_info(address=address2, notes=notes)
     contact_data.set_emails(first=email, second=email2, third=email3)
     contact_data.set_homepage(homepage)
     contact_data.set_phones(home=home, mobile=mobile, work=work, fax=fax, second_phone=phone2)
     return contact_data
def test_update_middle_contact(app, db, check_ui):
    # Prepare before test
    app.contact.prepare_contact_test_suite()
    # Prepare old contact data
    contact = Contact(firstname="Dave", middlename="JD", lastname="Doe", nickname="Tee")
    contact.set_company_data(title="MegaMailGroutOfAllWorld", company="MegaMailGroupOfAllWorldCorporation")
    contact.set_address(address="somewhere beyond the sea")
    contact.set_emails(first="*****@*****.**",
                       second="*****@*****.**", third="*****@*****.**")
    contact.set_homepage("www.somewherebeyondthesea.com")
    contact.set_phones(home="112223366", mobile="+7(000)9999911111222", work="44444433", fax="2300011",
                       second_phone="+123331212")
    contact.set_second_info(address="World 36", notes="She is my friend")
    contact.set_birthday(day="4", month="4", year="1987")
    contact.set_anniversary(day="31", month="7", year="2010")
    # Prepare new contact data
    new_contact = Contact(firstname="QAnny", middlename="QAA", lastname="QArnert", nickname="QTaT")
    new_contact.set_company_data(title="MegaMailGroutOfAllWorld2", company="MegaMailGroupOfAllWorldCorporation2")
    new_contact.set_address(address="somewhere beyond the sea2")
    new_contact.set_emails(first="*****@*****.**",
                           second="*****@*****.**", third="*****@*****.**")
    new_contact.set_homepage("www.somewherebeyondthesea2.com")
    new_contact.set_phones(home="112223377", mobile="+7(000)9999911111777", work="44444477", fax="2300077",
                           second_phone="+1233399")
    new_contact.set_second_info(address="World 77", notes="She is my best friend")
    new_contact.set_birthday(day="5", month="5", year="1986")
    new_contact.set_anniversary(day="12", month="3", year="2011")
    # Prepare other contacts
    first_contact = Contact(firstname="Ann", middlename="AT", lastname="Arner", nickname="Jay")
    third_contact = Contact(firstname="Leo", middlename="LLL", lastname="Lemon", nickname="Lem")
    # Create contacts
    app.contact.create(contact)
    app.contact.create(first_contact)
    app.contact.create(third_contact)
    old_contacts = app.contact.get_all_contacts()
    # Update contact
    new_contact.id = old_contacts[1].id
    app.contact.update_contact_from_list(2, new_contact)
    # Check contacts list
    old_contacts[1] = new_contact
    new_contacts = db.get_contact_list()
    app.contact.check_if_contacts_are_equal(old_contacts, new_contacts)
    if check_ui:
        new_contacts = app.contact.get_all_contacts()
        app.contact.check_if_contacts_are_equal(old_contacts, new_contacts)