示例#1
0
 def get_contacts_in_group(self,id_group):
     list = []
     cursor = self.connection.cursor()
     try:
         cursor.execute("""
                                select id,firstname,lastname,middlename,nickname,title,company,address,
                                home,mobile,work,fax,email,email2,email3,homepage,bday,bmonth,byear,
                                aday,amonth,ayear,address2,phone2,notes
                                from addressbook where deprecated='0000-00-00 00:00:00' and group_id='%s' """%id_group)
         for row in cursor:
             (id, firstname, lastname, middlename, nickname, title, company, address,
              homephone, mobilephone, workphone, fax, email, email2, email3, homepage, bday, bmonth, byear,
              aday, amonth, ayear, address2, secondaryphone, notes) = row
             list.append(ContactProperties(id=str(id), firstname=firstname, lastname=lastname,
                                           middlename=middlename, nickname=nickname, title=title, company=company,
                                           address=address,
                                           homephone=homephone, mobilephone=mobilephone, workphone=workphone,
                                           fax=fax,
                                           email=email, email2=email2, email3=email3, homepage=homepage, bday=bday,
                                           bmonth=bmonth, byear=byear,
                                           aday=aday, amonth=amonth, ayear=ayear, address2=address2,
                                           secondaryphone=secondaryphone, notes=notes
                                           ))
     finally:
         cursor.close()
     return list
示例#2
0
 def get_contact_from_view_page(self, index):
     wd = self.app.wd
     self.open_contact_view_by_index(index)
     text = wd.find_element_by_id("content").text
     homephone = re.search("H: (.*)", text).group(1)
     workphone = re.search("W: (.*)", text).group(1)
     mobilephone = re.search("M: (.*)", text).group(1)
     # fax=re.search("F: (.*)",text).group(1)
     secondaryphone = re.search("P: (.*)", text).group(1)
     return ContactProperties(
         homephone=homephone,
         mobilephone=mobilephone,
         workphone=workphone,
         # fax=fax,
         secondaryphone=secondaryphone)
示例#3
0
def test_delete_contact(app, check_ui, db):
    # photo path
    # p= os.path.abspath('C:\Users\hh\Pictures\Git.jpeg')
    if app.contact.count() == 0:
        app.contact.create(
            ContactProperties(firstname="delete check",
                              middlename="delete check",
                              lastname="delete check",
                              nickname="delete check",
                              photo="",
                              title="delete check",
                              company="delete check",
                              address="Adress2 Company2",
                              homephone="89776000000",
                              mobilephone="89776000001",
                              workphone="89776000002",
                              fax="89776000003",
                              email="*****@*****.**",
                              email2="*****@*****.**",
                              email3="*****@*****.**",
                              homepage="lev.tt.ru",
                              address2="New Secondary Adress",
                              secondaryphone=" New Secondary Home",
                              notes=" some new notes ver 2",
                              ayear="1999",
                              amonth="February",
                              aday="5",
                              byear="2001",
                              bmonth="June",
                              bday="17"))
    old_contacts = db.get_contact_list()
    contact = random.choice(old_contacts)
    app.contact.delete_contact_by_id(contact.id)
    new_contacts = db.get_contact_list()
    assert len(old_contacts) - 1 == len(new_contacts)
    old_contacts.remove(contact)
    assert old_contacts == new_contacts
    if check_ui:
        assert sorted(old_contacts, key=ContactProperties.id_or_max) == sorted(
            new_contacts, key=ContactProperties.id_or_max)
def test_add_contact_to_group(db, app, orm):
    if len(db.get_group_list()) == 0:
        app.group.create(Group(name="test group"))
    if app.contact.count() == 0:
        app.contact.create(
            ContactProperties(firstname="delete check",
                              middlename="delete check",
                              lastname="delete check",
                              nickname="delete check",
                              photo="",
                              title="delete check",
                              company="delete check",
                              address="Adress2 Company2",
                              homephone="89776000000",
                              mobilephone="89776000001",
                              workphone="89776000002",
                              fax="89776000003",
                              email="*****@*****.**",
                              email2="*****@*****.**",
                              email3="*****@*****.**",
                              homepage="lev.tt.ru",
                              address2="New Secondary Adress",
                              secondaryphone=" New Secondary Home",
                              notes=" some new notes ver 2",
                              ayear="1999",
                              amonth="February",
                              aday="5",
                              byear="2001",
                              bmonth="June",
                              bday="17"))

    groups = db.get_group_list()
    old_contacts = db.get_contact_list()
    contact_id = random.choice(old_contacts).id
    group_id = random.choice(groups).id
    app.contact.add_contact_to_group(contact_id, group_id)
    # не работает assert
    assert db.get_contact_by_id(contact_id) in orm.get_contacts_in_group(
        Group(id=group_id))
示例#5
0
    def get_contact_info_from_edit_page(self, index):
        wd = self.app.wd
        for row in wd.find_elements_by_xpath("//tr[@name='entry']"):
            self.open_contact_to_edit_by_index(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")
            homephone = wd.find_element_by_name("home").get_attribute("value")
            workphone = wd.find_element_by_name("work").get_attribute("value")
            mobilephone = wd.find_element_by_name("mobile").get_attribute(
                "value")
            fax = wd.find_element_by_name("fax").get_attribute("value")
            secondaryphone = 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")
            # homepage = wd.find_element_by_name("homepage").get_attribute("value")

            return ContactProperties(
                firstname=firstname,
                lastname=lastname,
                id=id,
                address=address,
                email=email,
                email2=email2,
                email3=email3,
                homephone=homephone,
                mobilephone=mobilephone,
                workphone=workphone,
                fax=fax,
                secondaryphone=secondaryphone,
                # homepage=homepage
            )
示例#6
0
    def get_contact_list(self):
        if self.contact_cashe is None:
            wd = self.app.wd
            self.return_to_home_page()
            self.contact_cashe = []
            for row in wd.find_elements_by_xpath("//tr[@name='entry']"):
                container = row.find_elements_by_tag_name("td")
                lastname = container[1].text
                firstname = container[2].text
                address = container[3].text
                all_emails = container[4].text
                id = container[0].find_element_by_tag_name(
                    "input").get_attribute("value")
                all_phones = container[5].text
                # homepage = container[9].
                self.contact_cashe.append(
                    ContactProperties(lastname=lastname,
                                      firstname=firstname,
                                      id=id,
                                      address=address,
                                      all_emails=all_emails,
                                      all_phones_from_home_page=all_phones))

        return list(self.contact_cashe)
示例#7
0

testdata = [
    ContactProperties(firstname=random_string("firstname", 20),
                      middlename=random_string("middlename", 20),
                      lastname=random_string("lastname", 20),
                      nickname=random_string("nickname", 10),
                      photo="",
                      title=random_string("title", 30),
                      company=random_string("company", 30),
                      address=random_string("address", 30),
                      homephone=random_phones("", 11),
                      mobilephone=random_phones("", 11),
                      workphone=random_phones("", 11),
                      fax=random_phones("", 11),
                      email=random_string("email@", 10),
                      email2=random_string("email@", 10),
                      email3=random_string("email@", 10),
                      homepage=random_string("http://", 15),
                      address2=random_string("address2", 30),
                      secondaryphone=random_phones("", 11),
                      notes=random_string("Notes", 40),
                      ayear=random.randint(1945, 2019),
                      amonth=random_month(),
                      aday=random.randint(1, 31),
                      byear=random.randint(1945, 2019),
                      bmonth=random_month(),
                      bday=random.randint(1, 31)) for i in range(n)
]

file = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", f)
示例#8
0
 def convert(contact):
     return ContactProperties(id = str(contact.id), firstname=contact.firstname,lastname= contact.lastname)
示例#9
0
def test_edit_contact(app, check_ui, db):
    if app.contact.count() == 0:
        app.contact.create(
            ContactProperties(firstname="edit check",
                              middlename="edit check",
                              lastname="edit check",
                              nickname="edit check",
                              photo="",
                              title="edit check",
                              company="edit check",
                              address="Adress2 Company2",
                              homephone="89776000000",
                              mobilephone="89776000001",
                              workphone="89776000002",
                              fax="89776000003",
                              email="*****@*****.**",
                              email2="*****@*****.**",
                              email3="*****@*****.**",
                              homepage="lev.tt.ru",
                              address2="New Secondary Adress",
                              secondaryphone=" New Secondary Home",
                              notes=" some new notes ver 2",
                              ayear="1999",
                              amonth="February",
                              aday="5",
                              byear="2001",
                              bmonth="June",
                              bday="17"))
    old_contacts = db.get_contact_list()
    contact = ContactProperties(firstname="Lev",
                                middlename="Radeon",
                                lastname="Akatiev",
                                nickname="kiriill",
                                photo="",
                                title="Title2",
                                company="Company2",
                                address="Adress2 Company2",
                                homephone="89776000000",
                                mobilephone="89776000001",
                                workphone="89776000002",
                                fax="89776000003",
                                email="*****@*****.**",
                                email2="*****@*****.**",
                                email3="*****@*****.**",
                                homepage="lev.tt.ru",
                                address2="edit",
                                secondaryphone=" edit Secondary Home",
                                notes=" some new notes ver 2",
                                ayear="2002",
                                amonth="February",
                                aday="8",
                                byear="2004",
                                bmonth="June",
                                bday="16")

    contact_to_edit = random.choice(old_contacts)
    app.contact.edit_contact_by_id(contact_to_edit.id, contact)
    new_contacts = db.get_contact_list()
    assert len(old_contacts) == len(new_contacts)
    if check_ui:
        assert sorted(app.contact.get_contact_list(),
                      key=ContactProperties.id_or_max) == sorted(
                          new_contacts, key=ContactProperties.id_or_max)