def test_modify_contact(app, db, check_ui): if len(db.get_contact_list()) == 0: app.group_new_contact.add_new_contact( New_contact(firstname="Alex", middlename="fffefe", lastname="wfawf", nickname="fwwfett", title="wfwfwer", company="erreeg", address="fwfawfaf fwfwaf fferwrr", homephone="454655665", mobilephone="89077777777", workphone="5656565656", fax="809876", email="*****@*****.**", email1="*****@*****.**", email2="*****@*****.**", email3="fwghehjrlt@ruru", address2="awwaagwg ffeef fefert", secondary_phone="89066666666", notes="awfawafwa fjfjhw fehgerrt")) old_contacts = db.get_contact_list() modify_contact = random.choice(old_contacts) contact = New_contact(firstname="Alex", middlename="fffefe", lastname="wfawf", nickname="fwwfett", title="wfwfwer", company="erreeg", address="fwfawfaf fwfwaf fferwrr", homephone="454655665", mobilephone="89077777777", workphone="5656565656", fax="809876", email="*****@*****.**", email1="*****@*****.**", email2="*****@*****.**", email3="fwghehjrlt@ruru", address2="awwaagwg ffeef fefert", secondary_phone="89066666666", notes="awfawafwa fjfjhw fehgerrt") contact.id = modify_contact.id app.group_new_contact.modify_contact_by_id(contact, contact.id) new_contacts = db.get_contact_list() assert len(old_contacts) == len(new_contacts) old_contacts = contact if check_ui: assert sorted(app.contact.get_contact_list(), key=New_contact.id_or_max) == sorted( new_contacts, key=New_contact.id_or_max)
def test_add_contact_to_group(app, orm): if len(orm.get_group_list()) == 0: app.group.create(Group(name="testtesttest")) if len(orm.get_contact_list()) == 0: app.group_new_contact.add_new_contact( New_contact(firstname="Alex", middlename="fffefe", lastname="wfawf", nickname="fwwfett", title="wfwfwer", company="erreeg", address="fwfawfaf fwfwaf fferwrr", homephone="454655665", mobilephone="89077777777", workphone="5656565656", fax="809876", email="*****@*****.**", email1="*****@*****.**", email2="*****@*****.**", email3="fwghehjrlt@ruru", address2="awwaagwg ffeef fefert", secondary_phone="89066666666", notes="awfawafwa fjfjhw fehgerrt")) all_groups = orm.get_group_list() group = random.choice(all_groups) all_contacts = orm.get_contact_list() contact = random.choice(all_contacts) if contact in (orm.get_contacts_in_group(group)): app.contact.delete_contact_from_group(contact, group) app.group_new_contact.add_contact_to_group(contact, group) assert contact in orm.get_contacts_in_group(group)
def test_all_fields_contact(app): if app.group_new_contact.count() == 0: app.group_new_contact.add_new_contact( New_contact(firstname="Alex", middlename="fffefe", lastname="wfawf", nickname="fwwfett", title="wfwfwer", company="erreeg", address="fwfawfaf fwfwaf fferwrr", homephone="454655665", mobilephone="89077777777", workphone="5656565656", fax="809876", email="*****@*****.**", email1="*****@*****.**", email2="*****@*****.**", email3="fwghehjrlt@ruru", address2="awwaagwg ffeef fefert", secondary_phone="89066666666", notes="awfawafwa fjfjhw fehgerrt")) all_contacts = app.contact.get_contact_list() index = randrange(len(all_contacts)) contact = all_contacts[index] contact_from_edit_page = app.contact.get_contact_info_from_edit_page( index) assert contact.all_phones_from_home_page == app.contact.merge_phones_like_on_home_page( contact_from_edit_page) assert contact.all_email == app.contact.merge_emails_like_on_home_page( contact_from_edit_page) assert contact.firstname == contact_from_edit_page.firstname assert contact.lastname == contact_from_edit_page.lastname assert contact.address == contact_from_edit_page.address
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") address = wd.find_element_by_name("address").get_attribute("value") id = wd.find_element_by_name("id").get_attribute("value") homephone = wd.find_element_by_name("home").get_attribute("value") workphone = wd.find_element_by_name("work").get_attribute("value") mobilephone = wd.find_element_by_name("mobile").get_attribute("value") secondary_phone = wd.find_element_by_name("phone2").get_attribute( "value") email1 = 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 New_contact(firstname=firstname, lastname=lastname, address=address, id=id, homephone=homephone, workphone=workphone, mobilephone=mobilephone, secondary_phone=secondary_phone, email1=email1, email2=email2, email3=email3)
def get_contact_list(self): contact_list = [] cursor = self.connection.cursor() try: cursor.execute( "select id, firstname, lastname, middlename, company, 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, middlename, company, address, home, mobile, work, phone2, email, email2, email3) = row contact_list.append( New_contact(id=str(id), firstname=firstname, lastname=lastname, middlename=middlename, company=company, address=address, homephone=home, mobilephone=mobile, workphone=work, secondary_phone=phone2, email1=email, email2=email2, email3=email3)) finally: cursor.close() return contact_list
def test_delete_contact(app, db): if len(db.get_contact_list()) == 0: app.group_new_contact.add_new_contact( New_contact(firstname="Alex", middlename="fffefe", lastname="wfawf", nickname="fwwfett", title="wfwfwer", company="erreeg", address="fwfawfaf fwfwaf fferwrr", homephone="454655665", mobilephone="89077777777", workphone="5656565656", fax="809876", email="*****@*****.**", email1="*****@*****.**", email2="*****@*****.**", email3="fwghehjrlt@ruru", address2="awwaagwg ffeef fefert", secondary_phone="89066666666", notes="awfawafwa fjfjhw fehgerrt")) old_contacts = db.get_contact_list() index = randrange(len(old_contacts)) app.group_new_contact.delete_contact_by_index(index) new_contacts = db.get_contact_list() assert len(old_contacts) - 1 == len(new_contacts) old_contacts[index:index + 1] = [] assert old_contacts == new_contacts
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) secondary_phone = re.search("P: (.*)", text).group(1) return New_contact(homephone=homephone, workphone=workphone, mobilephone=mobilephone, secondary_phone=secondary_phone)
def test_matching_all_contacts_db(app, db, check_ui): if len(db.get_contact_list()) == 0: app.group_new_contact.add_new_contact( New_contact(firstname="Alex", middlename="fffefe", lastname="wfawf", nickname="fwwfett", title="wfwfwer", company="erreeg", address="fwfawfaf fwfwaf fferwrr", homephone="454655665", mobilephone="89077777777", workphone="5656565656", fax="809876", email="*****@*****.**", email1="*****@*****.**", email2="*****@*****.**", email3="fwghehjrlt@ruru", address2="awwaagwg ffeef fefert", secondary_phone="89066666666", notes="awfawafwa fjfjhw fehgerrt")) contacts_all = sorted(app.group_new_contact.get_contact_list(), key=New_contact.id_or_max) contacts_from_db = sorted(db.get_contact_list(), key=New_contact.id_or_max) c = 0 for contact in contacts_all: contact_from_db = contacts_from_db[c] c = c+1 assert contact.firstname == contact_from_db.firstname assert contact.lastname == contact_from_db.lastname assert contact.address == contact_from_db.address assert contact.all_phones_from_home_page == app.group_new_contact.merge_phones_like_on_home_page(contact_from_db) assert contact.all_email == app.group_new_contact.merge_emails_like_on_home_page(contact_from_db)
def get_contact_list(self): if self.contact_cache is None: wd = self.app.wd self.app.open_home_page() self.contact_cache = [] for row in wd.find_elements_by_name("entry"): cells = row.find_elements_by_tag_name("td") lastname = cells[1].text firstname = cells[2].text address = cells[3].text all_email = cells[4].text all_phones = cells[5].text id = row.find_element_by_name("selected[]").get_attribute( "value") self.contact_cache.append( New_contact(firstname=firstname, lastname=lastname, id=id, address=address, all_phones_from_home_page=all_phones, all_email=all_email)) return list(self.contact_cache)
def convert(contact): return New_contact(id=str(contact.id), firstname=contact.firstname, lastname=contact.lastname)
from model.contact import New_contact testdata = [ New_contact(firstname="firstname1", middlename="middlename1", lastname="lastname1", address="address1", homephone="homephone1", mobilephone="mobilephone1", workphone="workphone1", email="email1", secondary_phone="secondary_phone1"), New_contact(firstname="firstname2", middlename="middlename2", lastname="lastname2", address="address2", homephone="homephone2", mobilephone="mobilephone2", workphone="workphone2", email="email2", secondary_phone="secondary_phone2"), ]
def clean(group_new_contact): return New_contact(id=group_new_contact.id, firstname=group_new_contact.firstname.strip(), lastname=group_new_contact.lastname.strip())