from fixtura.orm import ORMFixture from random import choice from model.Help_Class_Address import create_new_address db = ORMFixture(host='127.0.0.1', name='addressbook', user='******', password='') def test_delete_address_from_group(app): app.adress.open_address_page() old_groups = db.get_group_list() #old_address = db.get_contact_list() group_id = choice(old_groups).id #address_id = choice(old_address).id old_address_in_group = db.get_contacts_in_group(create_new_address(id='%s' % group_id)) app.group.select_group_dropdown(group_id) if len(db.get_contacts_in_group(create_new_address(id='%s' % group_id))) == 0: app.adress.click_dropdown() choise_address = app.adress.get_address_list() delete = choice(choise_address).id app.adress.click_checkbox(delete) app.group.click_on_value(group_id) list_of_address_in_choise_group = app.adress.get_address_list() choice_id_to_delete = choice(list_of_address_in_choise_group).id app.adress.select_address_checkbox(choice_id_to_delete) new_address_in_group = db.get_contacts_in_group(create_new_address(id='%s' % group_id))
import re from random import randrange """ def test_db_matches_data_from_home_page(app, db): all_contacts_from_ui = app.contact.get_contact_list() all_contacts_from_db = db.get_contact_list() assert sorted(all_contacts_from_ui, key=Contact.id_or_max) == sorted(all_contacts_from_db, key=Contact.id_or_max) def test_db_matches_data_from_home_page_use_orm(app, db): db = ORMFixture(host="127.0.0.1", name="addressbook", user="******", password="") all_contacts_from_ui = app.contact.get_contact_list() all_contacts_from_db = db.get_contact_list() assert sorted(all_contacts_from_ui, key=Contact.id_or_max) == sorted(all_contacts_from_db, key=Contact.id_or_max) """ db = ORMFixture(host="127.0.0.1", name="addressbook", user="******", password="") def test_db_matches_data_from_home_page_use_orm(app): contacts_from_home_page = sorted(app.contact.get_contact_list(), key=Contact.id_or_max) contacts_from_db = sorted(map(clean, db.get_contact_list()), key=Contact.id_or_max) print(contacts_from_db) print(contacts_from_home_page) for contact_from_hp, contact_from_db in zip(contacts_from_home_page, contacts_from_db): assert contact_from_hp.firstname == contact_from_db.firstname assert contact_from_hp.lastname == contact_from_db.lastname assert contact_from_hp.address == contact_from_db.address assert contact_from_hp.all_phones_from_home_page == merge_phones_like_on_home_page(
import pymysql.cursors from fixtura.orm import ORMFixture from model.group import Group db = ORMFixture(host = "127.0.0.1", name = "addressbook", user = "******", password = "") """ try: groups = db.get_group_list() for group in groups: print(group) print(len(groups)) finally: pass """ try: contacts = db.get_contacts_not_in_group(Group(id ="221")) for contact in contacts: print(contact) print(len(contacts)) finally: pass