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 get_contact_data(self): wd = self.app.wd text = wd.find_element_by_id("content").text home_phone = re.search("H: (.*)", text).group(1) work_phone = re.search("W: (.*)", text).group(1) mobile_phone = re.search("M: (.*)", text).group(1) secondary_phone = re.search("P: (.*)", text).group(1) new_contact = Contact() new_contact.set_phones(home=home_phone, mobile=mobile_phone, work=work_phone, second_phone=secondary_phone, fax=None) return new_contact
def test_check_all_contacts_on_main_page(app, db): if len(db.get_contact_list()) == 0: contact = Contact(firstname="Ann", middlename="AT", lastname="Arner", nickname="Tee") contact.set_phones(home="3321123", mobile="+792938232", work="44142221", second_phone="+791229313", fax="2123") app.contact.create(contact) contacts_from_main_page = app.contact.get_all_contacts() contacts_from_db = db.get_contact_list() for db_contact in contacts_from_db: value_found = False for web_contact in contacts_from_main_page: if db_contact.id == web_contact.id: value_found = True check_all_values_on_home_page(web_contact, db_contact) break if not value_found: raise ValueError('Contact with id %s not found on main page' % str(db_contact.id))
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)