Exemplo n.º 1
0
def new_contact_data(firstname, lastname, non_empty_contacts_list):
    new_contact = Contact(firstname=firstname,
                          lastname=lastname,
                          middlename='qwer',
                          nickname='asd',
                          title='fsdf',
                          company='fsd',
                          address='dfsdf',
                          homephone='45345',
                          mobilephone='2312',
                          workphone='2342',
                          fax='23213',
                          email='*****@*****.**',
                          email2='*****@*****.**',
                          email3='*****@*****.**',
                          homepage='sfsdfs.sdf',
                          byear='1900',
                          ayear='2000',
                          address2='sdfsdfsd',
                          secondaryphone='233534',
                          notes='dfsdf')
    contact = random.choice(non_empty_contacts_list)
    new_contact.id = contact.id
    new_contact.index = non_empty_contacts_list.index(contact)
    return new_contact
def test_modify_f_name(app, db, check_ui):
    if len(db.get_contact_list()) == 0:
        app.contact.add_new(Contact(f_name="Kevin"))
    old_contacts = db.get_contact_list()
    index = randrange(len(old_contacts))
    contact = Contact(f_name="Edward", l_name="Smith")
    contact.id = old_contacts[index].id
    app.contact.modify_contact_by_id(contact.id, contact)
    new_contacts = db.get_contact_list()
    assert len(old_contacts) == len(new_contacts)
    old_contacts[index] = contact
    if check_ui:
        assert sorted(old_contacts,
                      key=Contact.id_or_max) == sorted(new_contacts,
                                                       key=Contact.id_or_max)
def test_edit_contact(app, db, check_ui):
    new_contact = Contact(firstname='qqqqqqqqqqqq',
                          middlename='zxc',
                          lastname='xczxc',
                          nickname='zxc',
                          title='zc',
                          company='zc',
                          address='sfs',
                          homephone='4765765',
                          mobilephone='34234',
                          workphone='2342',
                          fax='345345',
                          email='*****@*****.**',
                          email2='*****@*****.**',
                          email3='*****@*****.**',
                          homepage='cvdfgdfg.sdf',
                          byear='1950',
                          ayear='2001',
                          address2='wefwefew',
                          secondaryphone='3345345',
                          notes='cdfgc')
    if len(db.get_contact_list()) == 0:
        app.contact.open_contact_page()
        app.contact.filing_contact_form(new_contact)
        app.contact.submit_contact_creation()
        app.open_homepage()
    old_contacts = db.get_contact_list()
    contact = random.choice(old_contacts)
    new_contact.id = contact.id
    index = old_contacts.index(contact)
    app.contact.modify_by_id(contact.id)
    app.contact.filling_contact_form(new_contact)
    app.contact.submit_contact_edition()
    app.open_homepage()
    #assert len(old_contacts) == app.contact.count()
    new_contacts = db.get_contact_list()
    old_contacts[index] = new_contact
    assert sorted(old_contacts,
                  key=Contact.id_or_max) == sorted(new_contacts,
                                                   key=Contact.id_or_max)
    if check_ui:
        assert sorted(new_contacts, key=Contact.id_or_max) == sorted(
            app.contact.get_contact_list(), key=Contact.id_or_max)
Exemplo n.º 4
0
def test_edit_firstname_contact_by_index(app, db, check_ui):
    if len(db.get_contact_list()) == 0:
        app.contact.create(Contact(firstname="Nkk", nickname="Lok"))

    old_contacts = db.get_contact_list()

    contact_by_edit = random.choice(old_contacts)
    contact = Contact(firstname="Lia")
    contact.id = contact_by_edit.id
    contact.lastname = contact_by_edit.lastname

    app.contact.edit_by_id(contact_by_edit.id, contact)
    new_contacts = db.get_contact_list()

    for element in old_contacts:
        if element == contact_by_edit:
            element.firstname = contact.firstname

    assert sorted(old_contacts, key=Contact.id_or_max) == sorted(
        new_contacts, key=Contact.id_or_max)
    if check_ui:
        assert sorted(new_contacts, key=Contact.id_or_max) == sorted(
            app.contact.get_contact_list(), key=Contact.id_or_max)
Exemplo n.º 5
0
def test_modify_contact_name(app, db, check_ui):
    with allure.step('Check contact'):
        if len(db.get_contact_list()) == 0:
            app.contact.creation(Contact(first_name="test"))
    with allure.step('Given a contact list and contact to modify'):
        old_contacts = db.get_contact_list()
        index = randrange(len(old_contacts))
        contact = Contact(first_name="NameTest",
                          middle_name="TT",
                          last_name="LastTest")
        contact.id = old_contacts[index].id
    with allure.step('When I change a contact info to %s' % contact):
        app.contact.modify_contact_by_id(contact, contact.id)
    with allure.step(
            'Then the new contact list is equal to the old list with new contact info'
    ):
        new_contacts = db.get_contact_list()
        assert len(old_contacts) == len(new_contacts)
        old_contacts[index] = contact
        assert old_contacts == new_contacts
        if check_ui:
            assert sorted(new_contacts, key=Contact.id_or_max) == sorted(
                app.group.get_contact_list(), key=Contact.id_or_max)
def test_modify_contact(app):
    # Get list of existing contacts
    old_contact_list = app.contact_page.get_list()
    contact_to_modify = Contact(
        first_name="first_name",
        last_name="last_name",
    )
    # Check if certain contact exist in list
    if contact_to_modify not in old_contact_list:
        app.group_page.create(
            contact_to_modify)  # if not then we create new contact
        old_contact_list = app.contact_page.get_list()

    # Find certain contact in list and determinate its ID
    modified_contact_index = old_contact_list.index(contact_to_modify)
    contact_to_modify.id = old_contact_list[modified_contact_index].id
    # Determinate fields to modify in new entity
    modified_contact = Contact(first_name="first_name1",
                               middle_name="middle_name1",
                               last_name="last_name1",
                               phone2="phone2-1",
                               notes="notes-1",
                               _id=contact_to_modify.id)
    # Modify contact in WEB
    app.contact_page.edit(contact_to_modify, modified_contact)

    # Assert result
    assert len(old_contact_list) == app.contact_page.count(
    )  # additional assert for list length in case of exception
    # Get updated contacts list
    new_contacts_list = app.contact_page.get_list()
    # Change modified contact in old list
    old_contact_list[modified_contact_index] = modified_contact
    # Assert result
    assert sorted(old_contact_list,
                  key=Contact.id_or_max) == sorted(new_contacts_list,
                                                   key=Contact.id_or_max)
def test_delete_some_contact(app):
    # Get list of existing contacts
    contact_to_delete = Contact(first_name="first_name1",
                                last_name="last_name1")
    contacts_list_len = app.contact_page.count()
    # Check the lenght of contact list
    if contacts_list_len == 0:
        app.contact_page.create(contact_to_delete)

    contacts_list = app.contact_page.get_list()
    index = randrange(len(contacts_list))
    # Find first contact in list and save its ID
    contact_to_delete.id = contacts_list[index].id
    contact_to_delete.first_name = contacts_list[index].first_name
    contact_to_delete.first_name = contacts_list[index].last_name
    #  Delete first contact from list
    app.contact_page.delete_by_index(index)

    # Assert result
    assert len(contacts_list) - 1 == app.contact_page.count(
    )  # check new length of contacts list
    # Get updated contacts list
    contacts_list = app.contact_page.get_list()
    assert contact_to_delete not in contacts_list  # check for deleted element existed
def test_delete_contact(app):
    # Get list of existing contacts
    contacts_list = app.contact_page.get_list()
    contact_to_delete = Contact(
        first_name="first_name1",
        last_name="last_name1",
    )
    # Check if certain contact exist in list
    if contact_to_delete not in contacts_list:
        app.group_page.create(
            contact_to_delete)  # if not then we create new contact
        contacts_list = app.contact_page.get_list()
    # Find certain contact in list and save its ID
    contact_to_delete_index = contacts_list.index(contact_to_delete)
    contact_to_delete.id = contacts_list[contact_to_delete_index].id
    #  Delete certain contact from list
    app.contact_page.delete(contact_to_delete)

    # Assert result
    assert len(contacts_list) - 1 == app.contact_page.count(
    )  # check new length of contacts list
    # Get updated contacts list
    contacts_list = app.contact_page.get_list()
    assert contact_to_delete not in contacts_list  # check for deleted element existed
Exemplo n.º 9
0
def test_edit_contact(app, db, check_ui):
    with pytest.allure.step('Given a non-empty contact list'):
        if len(db.get_contact_list()) == 0:
            app.contact.add(Contact(first_name="Contact_for_editing"))
        old_contacts = db.get_contact_list()
    with pytest.allure.step('Given a random contact from the list'):
        contact_for_editing = random.choice(old_contacts)
    with pytest.allure.step('Given a contact data'):
        data_for_editing = Contact(first_name="Updated_first_name",
                                   last_name="Updated_last_name")
        data_for_editing.id = contact_for_editing.id
    with pytest.allure.step('When I replace the data in selected contact'):
        app.contact.edit_contact_by_id(data_for_editing)
    with pytest.allure.step(
            ' Then the new contact list is equal to the old contact list with selected contact replaced by a new contact'
    ):
        new_contacts = db.get_contact_list()
        old_contacts.remove(contact_for_editing)
        old_contacts.append(data_for_editing)
        assert sorted(old_contacts, key=Contact.contact_id_or_max) == sorted(
            new_contacts, key=Contact.contact_id_or_max)
        if check_ui:
            assert sorted(new_contacts, key=Contact.contact_id_or_max) == \
                   sorted(app.contact.get_contact_list(), key=Contact.contact_id_or_max)
Exemplo n.º 10
0
    def _get_fields_from_edit_(self):
        wd = self.app.wd
        contact = Contact()
        # GET main fields
        contact.id = self._get_field_value_(By.NAME, "id")
        contact.first_name = self._get_field_value_(By.NAME, "firstname")
        contact.middle_name = self._get_field_value_(By.NAME, "middlename")
        contact.last_name = self._get_field_value_(By.NAME, "lastname")
        contact.nickname = self._get_field_value_(By.NAME, "nickname")

        # GET companies fields
        contact.company = self._get_field_value_(By.NAME, "company")
        contact.title = self._get_field_value_(By.NAME, "title")
        contact.address = self._get_field_value_(By.NAME, "address")

        # GET phones fields
        contact.home_phone = self._get_field_value_(By.NAME, "home")
        contact.mobile_phone = self._get_field_value_(By.NAME, "mobile")
        contact.work_phone = self._get_field_value_(By.NAME, "work")
        contact.fax_phone = self._get_field_value_(By.NAME, "fax")

        # GET email fields
        contact.email = self._get_field_value_(By.NAME, "email")
        contact.email2 = self._get_field_value_(By.NAME, "email2")
        contact.email3 = self._get_field_value_(By.NAME, "email3")
        contact.homepage = self._get_field_value_(By.NAME, "homepage")

        # TODO do some stuff for get value of selector
        # GET birthday date field
        # if contact.birth_date is not date.min and contact.birth_date is not None:
        #     b_day = contact.birth_date.day.__str__()
        #     b_month = contact.birth_date.strftime("%B")
        #     b_year = contact.birth_date.year.__int__()
        # else:
        #     b_day = None
        #     b_month = None
        #     = None
        # self._set_select_value_(By.XPATH, "//div[@id='content']/form/select[1]", b_day)
        # self._set_select_value_(By.XPATH, "//div[@id='content']/form/select[2]", b_month)
        # b_year = self._get_field_value_(By.NAME, "byear", b_year)
        # contact.birth_date = date(b_year,b_month,b_day)

        # GET anniversary date field
        # if contact.anniversary_date is not date.min and contact.anniversary_date is not None:
        #     a_day = contact.anniversary_date.day.__str__()
        #     a_month = contact.anniversary_date.strftime("%B")
        #     a_year = contact.anniversary_date.year.__int__()
        # else:
        #     a_day = None
        #     a_month = None
        #     a_year = None
        # self._set_select_value_(By.XPATH, "//div[@id='content']/form/select[3]", a_day)
        # self._set_select_value_(By.XPATH, "//div[@id='content']/form/select[4]", a_month)
        # a_year = self._get_field_value_(By.NAME, "ayear")
        # contact.birth_date = date(a_year, a_month, a_day)

        # GET address fields
        contact.address2 = self._get_field_value_(By.NAME, "address2")
        contact.phone2 = self._get_field_value_(By.NAME, "phone2")
        contact.notes = self._get_field_value_(By.NAME, "notes")
        # Return founded fields
        return contact