Example #1
0
def test_add_contact_in_group(app, orm, db):
    if len(db.get_contact_list()) == 0:
        app.Contacts.add_contact(Contact(firstname="test2"))
    if len(db.get_group_list()) == 0:
        app.group.create(Group(name="testName"))
    with pytest.allure.step('Given a group list'):
        selected_group = random.choice(orm.get_group_list())
    with pytest.allure.step('Given a contact_not_in_group'):
        contact_not_in_group = orm.get_contacts_not_in_group(selected_group)
    with pytest.allure.step('Given a contact_in_group'):
        contact_in_group = orm.get_contacts_in_group(selected_group)
    with pytest.allure.step('check contact list before add'):
        countact_before_adding = len(contact_in_group)
    if len(contact_not_in_group) == 0:
        app.Contacts.add_contact(
            Contact(firstname="Firstname",
                    lastname="Lastname",
                    address="Address"))
    contact_not_in_group = orm.get_contacts_not_in_group(selected_group)
    selected_contact = random.choice(contact_not_in_group)
    with pytest.allure.step('when select group list from group page'):
        app.group.select_group_from_home_page(selected_group.id)
    with pytest.allure.step('when added contact in group'):
        app.Contacts.add_contact_in_group(selected_contact.id)
    with pytest.allure.step('given a new contact list in group'):
        new_contact_in_group = orm.get_contacts_in_group(selected_group)
    with pytest.allure.step('then equal contacts before add with after add'):
        count_contact_in_group_after_adding_member = len(new_contact_in_group)
        assert countact_before_adding + 1 == count_contact_in_group_after_adding_member
Example #2
0
 def get_contact_info_from_editpage(self, index):
     wd = self.app.wd
     self.editsome_contact(index)
     firstname = wd.find_element_by_name("firstname").get_attribute("value")
     lastname = wd.find_element_by_name("lastname").get_attribute("value")
     id = wd.find_element_by_name("id").get_attribute("value")
     home = wd.find_element_by_name("home").get_attribute("value")
     work = wd.find_element_by_name("work").get_attribute("value")
     mobile = wd.find_element_by_name("mobile").get_attribute("value")
     phone2 = wd.find_element_by_name("phone2").get_attribute("value")
     address = wd.find_element_by_name("address").get_attribute("value")
     email = 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 Contact(id=id,
                    firstname=firstname,
                    lastname=lastname,
                    home=home,
                    mobile=mobile,
                    work=work,
                    phone2=phone2,
                    address=address,
                    email=email,
                    email2=email2,
                    email3=email3)
Example #3
0
 def get_contact_full_list(self):
     list = []
     cursor = self.connection.cursor()
     try:
         cursor.execute(
             "select id, firstname, lastname, 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, address, home, mobile, work, phone2,
              email, email2, email3) = row
             list.append(
                 Contact(id=str(id),
                         firstname=firstname,
                         lastname=lastname,
                         address=address,
                         email=email,
                         email2=email2,
                         email3=email3,
                         home=home,
                         mobile=mobile,
                         work=work,
                         phone2=phone2))
     finally:
         cursor.close()
     return list
Example #4
0
def test_edit_some_address(app, db, check_ui):
    if app.Contacts.count_contacts() == 0:
        app.Contacts.add_contact(Contact(firstname="test2"))

    old_address = db.get_contact_list()
    index = randrange(len(old_address))
    contact = Contact(firstname='firstname', lastname='lastname')
    contact.id = old_address[index].id
    app.Contacts.edit_contact_by_id(contact.id, contact)
    new_address = db.get_contact_list()
    assert len(old_address) == len(new_address)
    new_address = db.get_contact_list()
    old_address[index] = contact
    assert old_address == new_address
    if check_ui:
        contact_list = db.get_contact_full_list()
        assert sorted(contact_list, key=Contact.id_or_max) == sorted(
            app.Contacts.get_contact_list(), key=Contact.id_or_max)
Example #5
0
 def get_emails_from_view_page(self, index):
     wd = self.app.wd
     self.open_contact_view_by_index(index)
     for element in wd.find_elements_by_css_selector("div#content"):
         cells = element.find_elements_by_tag_name("a")
         email = cells[0].text
         email2 = cells[1].text
         email3 = cells[2].text
         return Contact(email=email, email2=email2, email3=email3)
Example #6
0
 def get_phone_from_view_page(self, index):
     wd = self.app.wd
     self.open_contact_view_by_index(index)
     text = wd.find_element_by_id("content").text
     home = re.search("H: (.*)", text).group(1)
     mobile = re.search("M: (.*)", text).group(1)
     work = re.search("W: (.*)", text).group(1)
     phone2 = re.search("P: (.*)", text).group(1)
     return Contact(home=home, work=work, mobile=mobile, phone2=phone2)
Example #7
0
def test_contact_list(app, db):
    if app.Contacts.count_contacts() == 0:
        app.Contacts.add_contact(Contact(firstname="test2"))

    ui_list = app.Contacts.get_contact_list()

    def clean(contact):
        return Contact(id=contact.id,
                       firstname=contact.firstname.strip(),
                       lastname=contact.lastname.strip())

    db_list = map(clean, db.get_contact_full_list())
    assert sorted(ui_list,
                  key=Contact.id_or_max) == sorted(db_list,
                                                   key=Contact.id_or_max)
Example #8
0
 def get_contact_phone_and_mail_list(self):
     list = []
     cursor = self.connection.cursor()
     try:
         cursor.execute(
             "select id, home, mobile, work, phone2, email, email2, email3 from addressbook"
         )
         for row in cursor:
             (id, home, mobile, work, phone2, email, email2, email3) = row
             list.append(
                 Contact(id=str(id),
                         all_phones_from_home_page=home + mobile + work +
                         phone2,
                         all_emails_from_home_page=email + email + email2 +
                         email3))
     finally:
         cursor.close()
     return list
Example #9
0
 def get_contact_list(self):
     list = []
     cursor = self.connection.cursor()
     try:
         cursor.execute(
             "select id, firstname, lastname, address, email, mobile from addressbook where deprecated ='0000-00-00 00:00:00'"
         )
         for row in cursor:
             (id, firstname, lastname, address, email, mobile) = row
             list.append(
                 Contact(id=str(id),
                         firstname=firstname,
                         lastname=lastname,
                         address=address,
                         mobile=mobile,
                         email=email))
     finally:
         cursor.close()
     return list
def test_assert_all_contacts_with_db (app, db):
    if app.Contacts.count_contacts() == 0:
        app.Contacts.add_contact(Contact(firstname="adadsad", lastname="adsdasd", address="sdadasd",email="asds add",home="sdasdsdad",
                                   mobile="8989989899"))
    else:
        pass
    contacts_from_home_page = app.Contacts.get_contact_list()
    contacts_from_db = db.get_contact_full_list()
    assert len(contacts_from_home_page) == len(contacts_from_db)

    contacts_from_home_page_sorted = sorted(contacts_from_home_page, key = Contact.id_or_max)
    contacts_from_db_sorted = sorted(contacts_from_db, key=Contact.id_or_max)


    for x in range(len(contacts_from_home_page_sorted)):
        assert contacts_from_home_page_sorted[x].lastname == contacts_from_db_sorted[x].lastname.strip()
        assert contacts_from_home_page_sorted[x].firstname == contacts_from_db_sorted[x].firstname.strip()
        assert contacts_from_home_page_sorted[x].address == contacts_from_db_sorted[x].address.strip()
        assert contacts_from_home_page_sorted[x].all_emails_from_home_page == merge_emails_like_on_home_page(contacts_from_db_sorted[x])
        assert contacts_from_home_page_sorted[x].all_phones_from_home_page == merge_phones_like_on_home_page(contacts_from_db_sorted[x])
def test_del_some_address(app, db, check_ui):
    if len(db.get_contact_list()) == 0:
        app.Contacts.add_contact(Contact(firstname="test2"))
    with pytest.allure.step('Given a old contact list'):
        old_address = db.get_contact_list()
    contact = random.choice(old_address)
    with pytest.allure.step('When i delete contact to the list'):
        app.Contacts.del_contact_by_id_with_allert(contact.id)
    with pytest.allure.step('Given a new contact list'):
        new_address = db.get_contact_list()
    with pytest.allure.step(
            'Then the new contact list equal to the old contact list with the delete contact'
    ):
        assert len(old_address) - 1 == app.Contacts.count_contacts()
        old_address.remove(contact)
        assert old_address == new_address
    if check_ui:
        contact_list = db.get_contact_phone_and_mail_list()
        assert sorted(contact_list, key=Contact.id_or_max) == sorted(
            app.Contacts.get_contact_list(), key=Contact.id_or_max)
Example #12
0
def test_delete_contact_in_group(app, orm, db):
    if len(db.get_contact_list()) == 0:
        app.Contacts.add_contact(Contact(firstname="test2"))
    if len(db.get_group_list()) == 0:
        app.group.create(Group(name="testName"))
    group_list = orm.get_group_list()
    contact_list = orm.get_contact_list()
    selected_group = random.choice(group_list)
    contact_list_from_group = orm.get_contacts_in_group(selected_group)
    if len(contact_list_from_group) == 0:
        selected_contact = random.choice(contact_list)
        app.group.select_group_from_home_page(selected_group.id)
        app.Contacts.add_contact_in_group(selected_contact.id)
        contact_list_from_group = orm.get_contacts_in_group(selected_group)
    count_contact_before_add = len(contact_list_from_group)
    selected_contact = random.choice(contact_list_from_group)
    app.Contacts.open_group_page_with_contact(selected_group.name)
    contact_index = contact_list_from_group.index(selected_contact)
    app.Contacts.delete_contact_from_group(selected_group.name, contact_index)
    contact_list = orm.get_contacts_in_group(selected_group)
    count_contact_after_add = len(contact_list)
    assert count_contact_before_add - 1 == count_contact_after_add
Example #13
0
 def get_contact_list(self):
     if self.contact_cache is None:
         wd = self.app.wd
         self.open_home_page()
         self.contact_cache = []
         for element in wd.find_elements_by_css_selector(
                 "tr[name='entry']"):
             id = element.find_element_by_name("selected[]").get_attribute(
                 "value")
             cells = element.find_elements_by_tag_name("td")
             l_name = cells[1].text
             f_name = cells[2].text
             address = cells[3].text
             all_phones = cells[5].text
             all_emails = cells[4].text
             self.contact_cache.append(
                 Contact(id=id,
                         firstname=f_name,
                         lastname=l_name,
                         all_phones_from_home_page=all_phones,
                         all_emails_from_home_page=all_emails,
                         address=address))
     return list(self.contact_cache)
Example #14
0
 def convert(contact):
     return Contact(id=str(contact.id),
                    firstname=contact.firstname,
                    lastname=contact.lastname)
Example #15
0
from Model.contact import Contact

Testdata = [Contact(firstname='firstname', lastname='lastname', address='address', mobile='mobile', email='email'),
            Contact(firstname='firstname2', lastname='lastname2', address='address2', mobile='mobilephone2', email='email12')
            ]
Example #16
0
 def clean(contact):
     return Contact(id=contact.id,
                    firstname=contact.firstname.strip(),
                    lastname=contact.lastname.strip())
Example #17
0
from Model.contact import Contact
from Model.model import Model
from View.view import View

print('Hello world!')

c = Contact('German', 'Neftali', '*****@*****.**', '4721005730')
print(c.email)

m = Model()
m.create_a_contact('Nefta', 'gonzalez', '*****@*****.**', '1245')
m.create_a_contact('Javier', 'escuela', '*****@*****.**', '145')
#m.create_a_contact('Oscar', 'Dominguez', '*****@*****.**', '12345')
print(m.read_all_contacts())
#print(m.read_a_contact('Javier', 'Lopez'))

m.update_a_contact('Javier', 'escuela', 'Nefta', 'gonzalez',
                   '*****@*****.**', '1545')
all_c = m.read_all_contacts()
contact = m.read_a_contact('Nefta', 'gonzalez')
print(m.read_all_contacts())
v = View()
v.show_a_contact(contact)

v.show_all_contacts(all_c)