コード例 #1
0
def test_modify_contact_firstname(app):
    precond_verifi_contact(app)
    old_contacts = app.contact.get_contact_list()
    index = randrange(len(old_contacts))
    contact = Group_contact(lastname="New_Name")
    contact.id = old_contacts[index].id
    app.contact.modify_contact_by_index(contact, index)
    new_contacts = app.contact.get_contact_list()
    assert len(old_contacts) == len(new_contacts)
    old_contacts[index] = contact
    assert sorted(old_contacts, key=Group_contact.id_or_max) == sorted(
        new_contacts, key=Group_contact.id_or_max)
コード例 #2
0
    def get_contact_info_from_edit_page(self, index):
        wd = self.app.wd
        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")
        mobile = wd.find_element_by_name("mobile").get_attribute("value")
        workphone = wd.find_element_by_name("work").get_attribute("value")
        fax = wd.find_element_by_name("fax").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 Group_contact(firstname=firstname,
                             lastname=lastname,
                             id=id,
                             homephone=homephone,
                             workphone=workphone,
                             mobile=mobile,
                             fax=fax,
                             address=address,
                             email=email,
                             email2=email2,
                             email3=email3)
コード例 #3
0
def test_add_contact(app):
    app.session.login(username="******", password="******")
    app.contact.select_first_contact()
    app.contact.button_Edit()
    app.contact.edit_contact_firm(Group_contact(firstname="Lex", middlename="Alex", lastname="Alex", nickname="Alex", title="Baaa", company="Bsss", address="Brrr", home="4", mobile="1111111",
                                     work="22222", fax="333", email="*****@*****.**", byear="1990", address2="ffff", phone2="fff", notes="ggg"))
    app.contact.button_Update()
    app.session.logout()
コード例 #4
0
def test_del_contact(app):
    if app.contact.count() == 0:
        app.contact.create(Group_contact(firstname="test"))
    old_contacts = app.contact.get_contact_list()
    index = randrange(len(old_contacts))
    app.contact.delete_contact_by_index(index)
    new_contacts = app.contact.get_contact_list()
    assert len(old_contacts) - 1 == len(new_contacts)
    old_contacts[index:index+1] = []
    assert old_contacts == new_contacts
コード例 #5
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
     home = re.search("H: (.*)", text).group(1)
     work = re.search("W: (.*)", text).group(1)
     mobile = re.search("M: (.*)", text).group(1)
     phone2 = re.search("P: (.*)", text).group(1)
     return Group_contact(home=home,
                          mobile=mobile,
                          work=work,
                          phone2=phone2)
コード例 #6
0
def test_contact_data_on_home_page_with_edit_page(app):
    if app.contact.count() == 0:
        app.contact.create(Group_contact(firstname="test"))
    index = randrange(len(app.contact.get_contact_list()))
    contact_from_home_page = app.contact.get_contact_list()[index]
    contact_from_edit_page = app.contact.get_contact_info_from_edit_page(index)
    assert contact_from_home_page.firstname == contact_from_edit_page.firstname
    assert contact_from_home_page.lastname == contact_from_edit_page.lastname
    assert contact_from_home_page.address == contact_from_edit_page.address
    assert contact_from_home_page.all_phones_from_home_page == merge_phones_like_on_home_page(
        contact_from_edit_page)
    assert contact_from_home_page.all_emails_from_home_page == merge_emails_like_on_home_page(
        contact_from_edit_page)
コード例 #7
0
def test_modify_contact_firstname(app):
    if app.contact.count() == 0:
        app.contact.create(
            Group_contact(firstname="Natalia", lastname="Aristova"))
    old_contacts = app.contact.get_contact_list()
    index = randrange(len(old_contacts))
    contact = Group_contact(firstname="Fedor", lastname="Aristov")
    contact.id = old_contacts[index].id
    #contact.firstname=old_contacts[0].firstname
    app.contact.modify_contact_by_index(index=index, new_contact_data=contact)
    new_contacts = app.contact.get_contact_list()
    assert len(old_contacts) == len(new_contacts)
    old_contacts[index] = contact
    assert sorted(old_contacts, key=Group_contact.id_or_max) == sorted(
        new_contacts, key=Group_contact.id_or_max)


#def test_modify_contact_middlename(app):
#   if app.contact.count() == 0:
#        app.contact.create(Group_contact(middlename="test"))
#   old_contacts = app.contact.get_contact_list()
#   app.contact.modify_first_contact(Group_contact(middlename="New middlename"))
#   new_contacts = app.contact.get_contact_list()
#  assert len(old_contacts) == len(new_contacts)
コード例 #8
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_name("entry"):
             cells = element.find_elements_by_tag_name("td")
             firstname = cells[2].text
             lastname = cells[1].text
             id = cells[0].find_element_by_tag_name("input").get_attribute(
                 "value")
             address = cells[3].text
             all_emails = cells[4].text
             all_phones = cells[5].text
             self.contact_cache.append(
                 Group_contact(firstname=firstname,
                               lastname=lastname,
                               id=id,
                               all_phones_from_page=all_phones,
                               all_emails_from_page=all_emails,
                               address=address))
     return list(self.contact_cache)
コード例 #9
0
 def get_contact_list(self):
     if self.contact_cache is None:
         wd = self.app.wd
         self.app.open_home_page()
         self.contact_cache = []
         for element in wd.find_elements_by_css_selector("tr[name=entry]"):
             cells = element.find_elements_by_tag_name("td")
             id = element.find_element_by_name("selected[]").get_attribute(
                 "value")
             lastname = cells[1].text
             firstname = cells[2].text
             address = cells[3].text
             all_phones = cells[5].text
             emails = cells[4].text
             self.contact_cache.append(
                 Group_contact(id=id,
                               lastname=lastname,
                               firstname=firstname,
                               all_emails_from_home_page=emails,
                               address=address,
                               all_phones_from_home_page=all_phones))
     return list(self.contact_cache)
コード例 #10
0
from model.group_contact import Group_contact

testdata = [
    Group_contact(firstname="firstname1",
                  middlename="middlename1",
                  lastname="lastname1",
                  nickname="nickname1",
                  title="title1"),
    Group_contact(firstname="firstname2",
                  middlename="middlename2",
                  lastname="lastname2",
                  nickname="nickname2",
                  title="title2")
]
コード例 #11
0
try:
    opts, args = getopt.getopt(sys.argv[1:],"n:f", ["number of contacts", "file"])
except getopt.GetoptError as err:
    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 = a
def random_string(prefix, maxlen):
    symbols = string.ascii_letters + string.digits + string.punctuation + " "
    return prefix+"".join([random.choice(symbols) for i in range(random.randrange(maxlen))])


testdata = [Group_contact(firstname ="", lastname="", mobile="", email="", email2="", email3="")] + \
           [Group_contact(firstname =random_string("firstname", 10), lastname=random_string("lastname", 10),
                          mobile=random_string("mobile", 10), email=random_string("email", 10))
    for i in range(n)]

file = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", f)

with open(file,"w") as out:
    jsonpickle.set_encoder_options("json", indent = 2)
    out.write(jsonpickle.encode(testdata))
コード例 #12
0
def precond_verifi_contact(app):
    if app.contact.count() == 0:
        app.contact.create_contact(Group_contact(firstname="Name"))
コード例 #13
0
f = "data/contacts.json"

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


def random_string(prefix, maxlen):
    symbols = string.ascii_letters + string.digits + "" * 10  #+ string.punctuation
    return prefix + "".join(
        [random.choice(symbols) for i in range(random.randrange(maxlen))])


testdata = [
    Group_contact(
        firstname="", middlename="", lastname="", nickname="", title="")
] + [
    Group_contact(firstname=random_string("firstname", 10),
                  middlename=random_string("middlename", 20),
                  lastname=random_string("lastname", 20),
                  nickname=random_string("nickname", 10),
                  title=random_string("title", 20)) for i in range(n)
]

file = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", f)

with open(file, "w") as out:
    jsonpickle.set_encoder_options("json", indent=2)
    out.write(jsonpickle.encode(testdata))