def test_add_group(app, data_groups, check_ui): adding_group = data_groups app.navigation.to_groups() if check_ui: old_groups = app.groups.get_groups() else: old_groups = app.orm.get_groups_list() app.groups.add_new_group(adding_group) app.navigation.to_groups() if check_ui: new_groups = app.groups.get_groups() else: new_groups = app.orm.get_groups_list() assert len(new_groups) == len(old_groups) + 1 old_groups.append(adding_group) assert list_sort(old_groups) == list_sort(new_groups)
def test_add_contact(app, data_contacts,check_ui): contact = data_contacts app.navigation.to_contacts() if check_ui: old_contacts = app.contacts.get_contacts() else: old_contacts = app.orm.get_contacts_list() len_old=len(old_contacts) app.contacts.add_new_contact(contact) app.navigation.to_contacts() if check_ui: new_contacts = app.contacts.get_contacts() else: new_contacts = app.orm.get_contacts_list() assert len(new_contacts) == (len_old + 1) old_contacts.append(contact) assert list_sort(new_contacts) == list_sort(old_contacts)
def test_remove_group(app, check_ui): app.groups.create_group_if_not_exist( Group("ToRemoveName", "ToRemoveHeader", "ToRemoveFooter", None)) app.navigation.to_groups() if check_ui: old_groups = app.groups.get_groups() else: old_groups = app.orm.get_groups_list() index = get_random_index_from_list(old_groups) app.groups.select_group_by_num_on_page(index) app.groups.delete() app.navigation.to_groups() if check_ui: new_groups = app.groups.get_groups() else: new_groups = app.orm.get_groups_list() assert len(old_groups) == len(new_groups) + 1 del old_groups[index] assert list_sort(old_groups) == list_sort(new_groups)
def test_remove_contact(app, check_ui): app.navigation.to_contacts() app.contacts.create_contact_if_not_exist( Contact("TestFirstName", "TestMiddleName", "TestLastName", None)) if check_ui: old_contacts = app.contacts.get_contacts() else: old_contacts = app.orm.get_contacts_list() len_contacts = len(old_contacts) index = get_random_index_from_list(old_contacts) app.navigation.to_contacts() app.contacts.remove_contact_by_num_on_page(index) app.navigation.to_contacts() if check_ui: new_contacts = app.contacts.get_contacts() else: new_contacts = app.orm.get_contacts_list() assert len(new_contacts) == len_contacts - 1 del old_contacts[index] assert list_sort(new_contacts) == list_sort(old_contacts)
def test_modify_group(app, check_ui): app.groups.create_group_if_not_exist( Group("ToModifiedName", "ToModifiedHeader", "ToModifiedFooter", None)) app.navigation.to_groups() if check_ui: old_groups = app.groups.get_groups() else: old_groups = app.orm.get_groups_list() index = get_random_index_from_list(old_groups) app.groups.select_group_by_num_on_page(index) modified_group = Group("ModifiedName", "ModifiedHeader", "ModifiedFooter", None) app.groups.modify(modified_group) app.navigation.to_groups() if check_ui: new_groups = app.groups.get_groups() else: new_groups = app.orm.get_groups_list() assert len(old_groups) == len(new_groups) del old_groups[index] old_groups.append(modified_group) assert list_sort(old_groups) == list_sort(new_groups)
def test_modify_contact(app, check_ui): app.navigation.to_contacts() app.contacts.create_contact_if_not_exist( Contact("TestFirstName", "TestMiddleName", "TestLastName", None)) app.navigation.to_contacts() if check_ui: old_contacts = app.contacts.get_contacts() else: old_contacts = app.orm.get_contacts_list() index = get_random_index_from_list(old_contacts) modified_contact = Contact("ModifiedFirstName", "ModifiedMiddleName", "ModifiedLastName", None) app.contacts.modify_contact_by_num_on_page(modified_contact, index) app.navigation.to_contacts() if check_ui: new_contacts = app.contacts.get_contacts() else: new_contacts = app.orm.get_contacts_list() del old_contacts[index] old_contacts.append(modified_contact) assert len(old_contacts) == len(new_contacts) assert list_sort(new_contacts) == list_sort(old_contacts)