Ejemplo n.º 1
0
    def get_contact_info_from_edit_page(self, index):
        wd = self.app.wd
        self.open_contact_to_edit_by_index(index)
        first_name = wd.find_element_by_name('firstname').get_attribute(
            'value')
        last_name = wd.find_element_by_name('lastname').get_attribute('value')
        my_id = wd.find_element_by_name('id').get_attribute('value')

        home_phone = wd.find_element_by_name('home').get_attribute('value')
        work_phone = wd.find_element_by_name('work').get_attribute('value')
        mobile_phone = wd.find_element_by_name('mobile').get_attribute('value')
        second_phone = wd.find_element_by_name('phone2').get_attribute('value')

        email1 = 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')
        address = wd.find_element_by_name('address').get_attribute('value')

        fax = wd.find_element_by_name('fax').get_attribute('value')

        return (Contact(first_name=first_name,
                        last_name=last_name,
                        id=my_id,
                        home=home_phone,
                        work=work_phone,
                        mobile=mobile_phone,
                        phone=second_phone,
                        email1=email1,
                        email2=email2,
                        email3=email3,
                        address=address,
                        fax=fax))
Ejemplo n.º 2
0
    def get_contact_info_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_phone = ''
        mobile_phone = ''
        work_phone = ''
        second_phone = ''
        fax = ''
        if re.search('H: (.*)', text):
            home_phone = re.search('H: (.*)', text).group(1)
        if re.search('M: (.*)', text):
            mobile_phone = re.search('M: (.*)', text).group(1)
        if re.search('W: (.*)', text):
            work_phone = re.search('W: (.*)', text).group(1)
        if re.search('P: (.*)', text):
            second_phone = re.search('P: (.*)', text).group(1)
        if re.search('F: (.*)', text):
            fax = re.search('F: (.*)', text).group(1)

        return Contact(home=home_phone,
                       work=work_phone,
                       mobile=mobile_phone,
                       phone=second_phone,
                       fax=fax)
Ejemplo n.º 3
0
def test_of_edit_contract(app):
    """
    Validation of edit contract
    """

    app.contact.validation_of_contact_exist()
    old_contact_list = app.contact.get_contact_list()
    index = randrange(len(old_contact_list))
    contact = Contact(first_name=Profinity.long_word_20, last_name=Profinity.long_word_20,
                      middle_name=Profinity.long_word_20, nickname=Profinity.long_word_20)
    contact.id = old_contact_list[index].id
    app.contact.edit_contract_by_index(contact, index)

    assert len(old_contact_list) == app.contact.count()
    new_contact_list = app.contact.get_contact_list()
    app.contact.delete_contact()

    old_contact_list[index] = contact
    assert sorted(old_contact_list, key=Contact.if_or_max) == sorted(new_contact_list, key=Contact.if_or_max)
Ejemplo n.º 4
0
 def validation_of_contact_exist(self):
     if self.count() == 0:
         self.create((Contact(first_name=Profinity.correct_data,
                              last_name=Profinity.correct_data,
                              middle_name=Profinity.correct_data,
                              nickname=Profinity.correct_data,
                              phone=Profinity.correct_phone_number,
                              work=Profinity.correct_phone_number,
                              home=Profinity.correct_phone_number,
                              mobile=Profinity.correct_phone_number)))
Ejemplo n.º 5
0
def test_of_edit_contract(app):
    """
    Validation of edit contract
    """

    app.contact.validation_of_contact_exist()
    old_contact_list = app.contact.get_contact_list()
    index = randrange(len(old_contact_list))
    contact = Contact(first_name=Profinity.long_word_20, last_name=Profinity.long_word_20,
                      middle_name=Profinity.long_word_20, nickname=Profinity.long_word_20)
    contact.id = old_contact_list[index].id
    app.contact.edit_contract_by_index(contact, index)

    assert len(old_contact_list) == app.contact.count()
    new_contact_list = app.contact.get_contact_list()
    app.contact.delete_contact()

    old_contact_list[index] = contact
    assert sorted(old_contact_list, key=Contact.if_or_max) == sorted(new_contact_list, key=Contact.if_or_max)
Ejemplo n.º 6
0
    def get_contact_list_without_none(self):
        if self.contract_cache is None:
            wd = self.app.wd
            self.open_contract_page()
            contract_cache = []
            for row in wd.find_elements_by_name('entry'):
                cells = row.find_elements_by_tag_name('td')
                my_id = cells[0].find_element_by_tag_name(
                    'input').get_attribute('value')
                all_phones = cells[5].text.splitlines()
                all_email = cells[4].text.splitlines()
                adress = cells[3].text.splitlines()

                a = ''
                b = ''
                c = ''
                d = ''
                e = ''
                f = ''
                g = ''
                h = ''
                if all_phones:
                    if len(all_phones) > 0 and all_phones[0]:
                        a = all_phones[0]
                    if len(all_phones) > 1 and all_phones[1]:
                        b = all_phones[1]
                    if len(all_phones) > 2 and all_phones[2]:
                        c = all_phones[2]
                    if len(all_phones) > 3 and all_phones[3]:
                        d = all_phones[3]

                if all_email:
                    if len(all_email) > 0 and all_email[0]:
                        e = all_email[0]
                    if len(all_email) > 1 and all_email[1]:
                        f = all_email[1]
                    if len(all_email) > 2 and all_email[2]:
                        g = all_email[2]
                if adress:
                    h = adress[0]

                contract_cache.append(
                    Contact(first_name=cells[1].text,
                            last_name=cells[2].text,
                            id=my_id,
                            home=a,
                            mobile=b,
                            work=c,
                            phone=d,
                            email1=e,
                            email2=f,
                            email3=g,
                            address=h))

            return contract_cache
Ejemplo n.º 7
0
def test_of_edit_contract(app, db, check_ui):
    """
    Validation of edit contract
    """

    app.contact.validation_of_contact_exist()
    old_contact_list = db.get_contact_list()

    contact = random.choice(old_contact_list)
    old_contact_list.remove(contact)
    contact_id = contact.id

    contact = Contact(first_name=Profinity.long_word_20, last_name=Profinity.long_word_20,
                      middle_name=Profinity.long_word_20, nickname=Profinity.long_word_20)

    contact.id = contact_id
    app.contact.edit_contact_by_id(contact, contact_id)

    new_contact_list = db.get_contact_list()

    old_contact_list.append(contact)

    validate_contact_list(app, old_contact_list, new_contact_list, check_ui)
    app.contact.delete_contact()
Ejemplo n.º 8
0
    getopt.usage()
    sys.exit(2)

n = 5
f = 'data/contact.json'

for o, a in opts:
    if o == "-n":
        n=int(a)
    elif o == "-f":
        f = str(a)

test_data = [
    Contact(first_name='', middle_name='', last_name='', nickname='', title='',
            company_name='', address_name='', home='', mobile='', work='', fax='',
            email1='', email2='', email3='', homepage='', address='', phone='', notes='',
            id='', contact_name='')]+[Contact(first_name=random_string('first_name', 10),
                                              middle_name=random_string('middle_name', 20),
                                              last_name=random_string('last_name', 20),
                                              nickname=random_string('nickname', 10),
                                              title=random_string('title', 20),
                                              company_name=random_string('company_name', 20),
                                              address_name=random_string('address_name', 10),
                                              home=random_string('home', 20),
                                              mobile=random_string('mobile', 20),
                                              work=random_string('work', 10),
                                              fax=random_string('fax', 20),
                                              email1=random_string('email1', 20),
                                              email2=random_string('email2', 10),
                                              email3=random_string('email3', 20),
                                              homepage=random_string('homepage', 20),
Ejemplo n.º 9
0
        fax = ''
        if re.search('H: (.*)', text):
            home_phone = re.search('H: (.*)', text).group(1)
        if re.search('M: (.*)', text):
            mobile_phone = re.search('M: (.*)', text).group(1)
        if re.search('W: (.*)', text):
            work_phone = re.search('W: (.*)', text).group(1)
        if re.search('P: (.*)', text):
            second_phone = re.search('P: (.*)', text).group(1)
        if re.search('F: (.*)', text):
            fax = re.search('F: (.*)', text).group(1)

        return Contact(home=home_phone,
                       work=work_phone,
                       mobile=mobile_phone,
                       phone=second_phone,
                       fax=fax)


# all data old
'''
Contact(first_name=Profinity.correct_data, last_name=Profinity.correct_data,
                      middle_name=Profinity.correct_data, nickname=Profinity.correct_data,
                      title=Profinity.correct_data, company_name=Profinity.correct_data,
                      address_name=Profinity.correct_data, work=Profinity.correct_phone_number,
                      fax=Profinity.correct_phone_number, home=Profinity.correct_phone_number,
                      mobile=Profinity.correct_phone_number, email1=Profinity.correct_email,
                      email2=Profinity.correct_email, email3=Profinity.correct_email, homepage=Profinity.correct_data,
                      add_year=True, address=Profinity.correct_data, phone=Profinity.correct_data,
                      notes=Profinity.correct_data)
'''
Ejemplo n.º 10
0
from fixture.TestBase import random_string
from tests_contract.contact_helper import Contact
from fixture.variables import Profinity

constant = [
    Contact(first_name=Profinity.correct_data,
            last_name=Profinity.correct_data,
            middle_name=Profinity.correct_data,
            nickname=Profinity.correct_data,
            title=Profinity.correct_data,
            company_name=Profinity.correct_data,
            address_name=Profinity.correct_data,
            work=Profinity.correct_phone_number,
            fax=Profinity.correct_phone_number,
            home=Profinity.correct_phone_number,
            mobile=Profinity.correct_phone_number,
            email1=Profinity.correct_email,
            email2=Profinity.correct_email,
            email3=Profinity.correct_email,
            homepage=Profinity.correct_data,
            add_year=True,
            address=Profinity.correct_data,
            phone=Profinity.correct_data,
            notes=Profinity.correct_data),
    Contact(first_name=Profinity.correct_data,
            last_name=Profinity.correct_data,
            middle_name=Profinity.correct_data,
            nickname=Profinity.correct_data,
            title=Profinity.correct_data,
            company_name=Profinity.correct_data,