def test_mod_contact_name(app, orm, check_ui): if len(orm.get_addnew_list()) == 0: app.addnew.createnew(CONTACT(name="Alisa")) old_addnews = orm.get_addnew_list() new_addnew = CONTACT(name="Klavdiya") mod_addnew = random.choice(old_addnews) new_addnew.id = mod_addnew.id if new_addnew.name is None: new_addnew.name = mod_addnew.name if new_addnew.lastname is None: new_addnew.lastname = mod_addnew.lastname app.addnew.mod_contact_by_id(mod_addnew.id, new_addnew) new_addnews = orm.get_addnew_list() old_addnews.remove(mod_addnew) old_addnews.append(new_addnew) assert sorted(old_addnews, key=CONTACT.id_or_max) == sorted(new_addnews, key=CONTACT.id_or_max) if check_ui: assert sorted(new_addnews, key=CONTACT.id_or_max) == sorted( app.addnew.get_addnew_list(), key=CONTACT.id_or_max)
def test_modifyok_contact(app, db, check_ui): if len(db.get_add_new_list()) == 0: app.add_new.create(CONTACT(name="test")) app.open_home_page() old_contacts = db.get_add_new_list() mod_contact = random.choice(old_contacts) new_contact = CONTACT(name="New contact") new_contact.id = mod_contact.id if new_contact.name is None: new_contact.name = mod_contact.name if new_contact.lastname is None: new_contact.lastname = mod_contact.lastname id = new_contact.id app.add_new.modifyok_contact_by_id(id, new_contact) new_contacts = db.get_add_new_list() old_contacts.remove(mod_contact) old_contacts.append(new_contact) assert sorted(old_contacts, key=CONTACT.id_or_max) == sorted(new_contacts, key=CONTACT.id_or_max) if check_ui: assert sorted(old_contacts, key=CONTACT.id_or_max) == sorted( app.add_new.get_add_new_list(), key=CONTACT.id_or_max)