def test_modify_contact(fixt):
    if fixt.contact.count_contacts() == 0:
        fixt.contact.create(ContactFormAttributes(firstname="firstname", lastname="lastname"))
    old_contacts = fixt.contact.get_contact_list()

    # random choose contact
    index = randrange(len(old_contacts))
    contact = ContactFormAttributes(firstname="modified")
    contact.id = old_contacts[index].id
    fixt.contact.modify_contact_by_index(index, contact)
    assert len(old_contacts) == fixt.contact.count_contacts()

    new_contacts = fixt.contact.get_contact_list()
    old_contacts[index] = contact
    assert sorted(old_contacts, key=ContactFormAttributes.id_or_max) == sorted(new_contacts,
                                                                               key=ContactFormAttributes.id_or_max)
Пример #2
0
    def get_contact_info_from_edit_page(self, index):
        wd = self.fixt.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")
        workphone = wd.find_element_by_name("work").get_attribute("value")
        mobilephone = wd.find_element_by_name("mobile").get_attribute("value")
        phone2 = 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")

        return ContactFormAttributes(firstname=firstname,
                                     lastname=lastname,
                                     id=id,
                                     homephone=homephone,
                                     workphone=workphone,
                                     mobilephone=mobilephone,
                                     phone2=phone2,
                                     email1=email1,
                                     email2=email2,
                                     email3=email3,
                                     address=address)
Пример #3
0
 def get_contact_list(self):
     if self.contact_cache is None:
         wd = self.fixt.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")
             #lastname
             text = cells[1].text
             #firstname
             text2 = cells[2].text
             id = cells[0].find_element_by_tag_name("input").get_attribute(
                 "value")
             all_phones = cells[5].text
             all_emails = cells[4].text
             address = cells[3].text
             self.contact_cache.append(
                 ContactFormAttributes(
                     firstname=text2,
                     lastname=text,
                     id=id,
                     address=address,
                     all_phones_from_home_page=all_phones,
                     all_emails_from_home_page=all_emails))
     return list(self.contact_cache)
Пример #4
0
    def get_contact_from_view_page(self, index):
        wd = self.fixt.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)
        phone2 = re.search("P: (.*)", text).group(1)

        return ContactFormAttributes(homephone=homephone,
                                     workphone=workphone,
                                     mobilephone=mobilephone,
                                     phone2=phone2)
def test_delete_first_contact(fixt):
    if fixt.contact.count_contacts() == 0:
        fixt.contact.create(
            ContactFormAttributes(firstname="firstname", lastname="lastname"))
    old_contacts = fixt.contact.get_contact_list()

    #random choose contact
    index = randrange(len(old_contacts))
    fixt.contact.delete_contact_by_index(index)
    assert len(old_contacts) - 1 == fixt.contact.count_contacts()

    new_contacts = fixt.contact.get_contact_list()
    old_contacts[index:index + 1] = []
    assert old_contacts == new_contacts
Пример #6
0
    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/contacts.json"

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


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


test_data = [ContactFormAttributes(firstname="", middlename="", homephone="", byear="1991")] + [
    ContactFormAttributes(firstname=random_string(10), middlename=random_string(10), lastname=random_string(10),
                          homephone=random_string(10), email1=random_string(10), byear="1991", notes=random_string(10))
    for i in range(5)
]

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(test_data))
Пример #7
0
from git.model.contact import ContactFormAttributes

testdata = [
    ContactFormAttributes(firstname="",
                          middlename="",
                          homephone="",
                          byear="1991"),
    ContactFormAttributes(firstname="test1",
                          middlename="test2",
                          homephone="+7 (495) 510-55-55",
                          byear="1991"),
    ContactFormAttributes(firstname="Marry",
                          lastname="Poppins",
                          homephone="+7 (000) 000-00-00",
                          byear="1920")
]